Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60807 > unrolled thread

Re: any lib to convert 3200+ pic to animated gif?

Started byChris Angelico <rosuav@gmail.com>
First post2013-12-01 01:38 +1100
Last post2013-12-01 01:38 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: any lib to convert 3200+ pic to animated gif? Chris Angelico <rosuav@gmail.com> - 2013-12-01 01:38 +1100

#60807 — Re: any lib to convert 3200+ pic to animated gif?

FromChris Angelico <rosuav@gmail.com>
Date2013-12-01 01:38 +1100
SubjectRe: any lib to convert 3200+ pic to animated gif?
Message-ID<mailman.3424.1385822333.18130.python-list@python.org>
On Sun, Dec 1, 2013 at 1:21 AM, oyster <lepto.python@gmail.com> wrote:
> I want to make an animated GIF from 3200+ png
> I searched and found http://code.google.com/p/visvis/source/browse/#hg/vvmovie
> and I wrote:
> allPic=glob.glob('*.png')
> allPic.sort()
> allPic=[Image.open(i) 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 Image.open() calls will create, but possibly
not verify, the images. Does this work?

images = []
for pic in allPic:
    img = Image.open(pic)
    img.verify()
    images.append(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:

https://mail.python.org/mailman/listinfo/image-sig

Hope that helps!

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web