top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Python: any library to convert large number of pictures animated gif?

+4 votes
2,033 views

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

 allPic=[Image.open(i) for i in allPic]
 File "e:prgpypython-2.7.3libsite-packagesPILImage.py", line 1952, in open
 fp = __builtin__.open(fp, "rb")
IOError: [Errno 24] Too many open files: 'out0572.png'

Is there other lib for py?

posted Nov 30, 2013 by Anderson

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

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:

answer Nov 30, 2013 by anonymous
Similar Questions
+7 votes

I want to create a GIF file in which some object is constant and some object and changing its position over time. Any suggestion on how to achieve this?

+1 vote

I have about 500 search queries, and about 52000 files in which I have to find all matches for each of the 500 queries.

How should I approach this? Seems like the straightforward way to do it would be to loop through each of the files and go line by line comparing all the terms to the query, but this seems like it would take too long.

Can someone give me a suggestion as to how to minimize the search time?

+1 vote

Hello all,Im looking for speech to text conversation python library for linux and mac box, I found few libraries but non of them supports any of these platform.I found following libraries speech, dragonfly and pyspeech supports only windows and sphinx for linux.

+2 votes

I have a numpy array consisting of 1s and zeros for representing binary numbers:

e.g.

 >>> binary
 array([ 1., 0., 1., 0.])

I wish the array to be in the form 1010, so it can be manipulated. I do not want to use built in binary converters as I am trying to build my own.

...