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

Alan Gauld alan.gauld at btinternet.com
Tue Nov 18 12:42:39 CET 2014


On 18/11/14 09:24, Jason Y wrote:

> 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.

In addition to my earlier comments I meant to add that you could 
consider creating a couple of helper functions:

1) to generate the filename from the file number

def nextFile(fnumber): ....

2) to resize the image

def resize(im):...


Your main loop then looks something like

while fileNumber < target:
     fname = nextFile(filenumber)
     im = Image(fname)
     resize(im)
     filenumber +=1


hth
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my phopto-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list