Is there a max number of .png files that I can append to create a .gif file with imageio?

14 views
Skip to first unread message

Nirandika Wanigasekara

unread,
Jun 20, 2017, 10:47:01 PM6/20/17
to imageio
I am using the following code to create a .gif file from .png files. I am trying to append around 3000 .png files. Eventhough filenames array has all the files I need to append the resulting .gif file has only 756 .png files. 

Is this a limitation with imageio? Have you limited some memory constraints for mode ='I', if so how can I override it? What other alternative solution do I have to create a .gif from 3000 .png files?

Hope someone can help me with this. Thank you!

import imageio
import os

filenames =[]
dirPath = "D:\\BandSim_2017-06-20_12_00_45\\"
for file in os.listdir(dirPath):
if file.endswith(".png"):
filenames.append(dirPath+file)

# print filenames
moviePath ="D:\\simulation.gif"
with imageio.get_writer(moviePath,format='gif', mode='I', duration=0.1, loop=1) as writer:
i=0
for filename in filenames[0:7 ]:
image = imageio.mimread(filename)
writer.append_data(image)
print filename
writer.close()

Almar Klein

unread,
Jun 21, 2017, 3:23:41 AM6/21/17
to ima...@googlegroups.com

Hi Nirandika,

 

No, especially when used properly, as you are doing, the writer should not have any memory limits, as new data is added to the file and not kept in memory.

 

I do see that you’re sliceing the filenames list, and i never seems to be increased. How have you found the number of images in the resulting GIF?

 

- Almar

--
You received this message because you are subscribed to the Google Groups "imageio" group.
To unsubscribe from this group and stop receiving emails from it, send an email to imageio+u...@googlegroups.com.
To post to this group, send email to ima...@googlegroups.com.
Visit this group at https://groups.google.com/group/imageio.
For more options, visit https://groups.google.com/d/optout.

 

Nirandika Wanigasekara

unread,
Jun 21, 2017, 8:24:39 AM6/21/17
to imageio
Hi Almar, 

I have a unique number in each image which is increasing one by one. This is how I find the number of .png files in the gif. 

Something seems to be prohibiting me from appending more than 756 images. Would be nice to know why. 

Almar Klein

unread,
Jun 21, 2017, 5:41:49 PM6/21/17
to ima...@googlegroups.com

Could you increase i in the loop and verify that its 3000 when it finishes (i.e. append_data() is called 3000 times)? That should narrow it down a bit.

 

Thanks,

Reply all
Reply to author
Forward
0 new messages