[Tutor] Trying to use the Pillow library to create a gif

Jason Y kymotsujason at live.com
Tue Nov 18 10:24:46 CET 2014


Hi,~This is a university assignment I'm working on.I have approximately 720 images all using the format "a ###.jpg", where # is a number (ie. "a 001.jpg").With these images, I'm attempting to create a gif by resizing an image (a 001.jpg) 10 times and than use a recursive function that should use the next image (a 002.jpg) and resize that 10 times, etc...; until it reaches "a 721.jpg", where it should stop.I'm not familiar with the Pillow library in python, so I'm kind of at a wall right now.I'm also sure there are plenty of errors or inefficiency in this code.This will run; however, it will not go on to the next image. I've tried a few things to manipulate the string "a 001.jpg".Anyone?
from PIL import Images = ("a 001.jpg")im = Image.open(s)def main(im):    try:        x = 920        y = 80        for a in range(0,10):            x += 100            y += 100            box = (x,y)            im = im.resize(box)            im.show()        s = list(s)        if s[4] < 9:            s[4] = int(s[4]) + 1        elif s[4] == 9:            s[4] = 0            s[3] = int(s[3]) + 1        elif s[3] < 9:            s[3] = int(s[3]) + 1        elif s[3] == 9:            s[3] = 0            s[2] = int(s[2]) + 1        elif s[2] < 9:            s[2] = int(s[2]) + 1        elif s[2] == 9:            s[2] = 0        s = ''.join(s)        im = Image.open(s)        return main(im)    except:        return -1main(im)
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141118/833f79f6/attachment.html>


More information about the Tutor mailing list