python 逆向播放gif

来源:互联网 发布:笔记本安装mac os x 编辑:程序博客网 时间:2024/05/16 08:13

从头条看到的

from PIL import Image, ImageSequencefrom PIL import ImagePalettewith Image.open('sd.gif') as im:    if im.is_animated:        frames = [f.copy() for f in ImageSequence.Iterator(im)]        frames.reverse()        frames[0].save('out.gif', save_all=True, append_images = frames[1:])   

路过大佬给看下错误,gif图能输出,就是报错

Couldn’t allocate palette entry for transparency “for transparency”)


一个python闯关:

# coding:utf-8import requestsfrom PIL import Imageimport urllib2import reimport StringIOdef getChanllenge(p):    return urllib2.urlopen('http://www.pythonchallenge.com/pc/' + p).read()def get_images(s):    return Image.open(StringIO.StringIO(getChanllenge(s)))im = get_images('def/oxygen.png')w, h = im.sizeprint im.getpixel((0,h//2))print chr(115)print ''.join([chr(im.getpixel((i, h//2))[0]) for i in range(0,w,8)])##guess another pixel almost about 8print ''.join([chr(im.getpixel((i, h//2))[0]) for i in range(0,w,7)])print ''.join(map(chr, [105, 110, 116, 101, 103, 114, 105, 116, 121]))
0 0
原创粉丝点击