I'm trying to create a gif image from several (in this case only 5) png files. I can create the gif if I debug the code at the point the looping through the images occurs. Otherwise the execution appears to be too fast. Here is my code:
img, *imgs = [Image.open(f) for f in sorted(glob.glob(png_in))]
So I flattened the list comprehension and added and played around with the time.sleep(x)
:
ImageFile.LOAD_TRUNCATED_IMAGES = True
imgs = []
for f in sorted(glob.glob(png_in)):
i = Image.open(f)
time.sleep(1)
imgs.append(i)
Then instead of using the PIL module, I switched to the imageio
module:
images = []
png_list = sorted(glob.glob(png_in))
for filename in png_list:
print(f"fn: {filename}")
images.append(imageio.imread(filename))
time.sleep(1)
imageio.mimsave(gif_file, images)
Any ideas where I may be going wrong? The error message I get, for example, is:
unknown element "blank"
i = Image.open(f)