Changed gifmaker script to use ImageSequence Iterator

This commit is contained in:
Andrew Murray 2015-06-20 23:52:02 +10:00
parent 40ae907342
commit 6d7eb53b52

View File

@ -42,26 +42,10 @@
from __future__ import print_function
from PIL import Image, ImageChops
from PIL import Image, ImageChops, ImageSequence
from PIL.GifImagePlugin import getheader, getdata
# --------------------------------------------------------------------
# sequence iterator
class image_sequence(object):
def __init__(self, im):
self.im = im
def __getitem__(self, ix):
try:
if ix:
self.im.seek(ix)
return self.im
except EOFError:
raise IndexError # end of sequence
# --------------------------------------------------------------------
# straightforward delta encoding
@ -122,7 +106,7 @@ def compress(infile, outfile):
# open output file
fp = open(outfile, "wb")
seq = image_sequence(im)
seq = ImageSequence.Iterator(im)
makedelta(fp, seq)