any lib to convert 3200+ pic to animated gif?

Chris Angelico rosuav at
Sat Nov 30 15:38:43 CET 2013

On Sun, Dec 1, 2013 at 1:21 AM, oyster <lepto.python at> wrote:
> I want to make an animated GIF from 3200+ png
> I searched and found
> and I wrote:
> allPic=glob.glob('*.png')
> allPic.sort()
> allPic=[ for i in allPic]
> writeGif('lala3.gif',allPic, duration=0.5, dither=0)
> However I got
> IOError: [Errno 24] Too many open files: 'out0572.png'

Yes, trying to open 3200 files is likely to be a problem!

The question is, how can you load them into memory one by one, and
keep closing them? I'm not very familiar with PIL, but a glance at the
code suggests that the calls will create, but possibly
not verify, the images. Does this work?

images = []
for pic in allPic:
    img =
allPic = images

Use that instead of your list comprehension. In theory, at least, that
should abandon the file objects (not explicitly closing them, alas,
but abandoning them should result in them being closed in CPython), so
you ought to get them all opened and read.

Otherwise, someone with more knowledge of PIL may be able to help.
According to the PIL docs, this list may be more focussed on what
you're trying to do, so if you don't get a response here, try there:

Hope that helps!


More information about the Python-list mailing list