pbfy0 / visvis

Automatically exported from code.google.com/p/visvis
Other
0 stars 0 forks source link

error with images2gif.py #76

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. writeGif(filename, images, duration)
2.
3.

What is the expected output? What do you see instead?
Expect to create GIF file, instead got error message:
File "C:\Python27\lib\site-packages\visvis\vvmovie\images2gif.py", line 436, in 
writeGifToFile
    fp.write(globalPalette)
TypeError: must be string or buffer, not list

What version of the product are you using? On what operating system?
Python 2.7.5, pillow 2.1.0, visvis 1.8, on Windows 7 32-bit.

Please provide any additional information below.

Original issue reported on code.google.com by Wenzao...@gmail.com on 20 Aug 2013 at 5:05

GoogleCodeExporter commented 9 years ago
Did you try to make images a list of numpy arrays?

Original comment by almar.klein@gmail.com on 20 Aug 2013 at 5:49

GoogleCodeExporter commented 9 years ago
I'm not sure... This is my exact code, 

import glob
from PIL import Image
from visvis.vvmovie.images2gif import writeGif

images = [Image.open(image) for image in glob.glob("*.png")]
filename = "test.gif"
writeGif(filename, images, duration=0.2)

Did I do anything wrong? How do I make it a list of numpy arrays?

Original comment by Wenzao...@gmail.com on 20 Aug 2013 at 6:01

GoogleCodeExporter commented 9 years ago
Now you have PIL images. That *should* work too. I usually use it with numpy 
arrays though, so you could try that instead.

I don't know from the top of my hand how to turn a PIL image into a numpy 
array, but it should be straightforward.

Also you could do:
images = [visvis.imread(image) for image in glob.glob("*.png")]

Original comment by almar.klein@gmail.com on 20 Aug 2013 at 6:54

GoogleCodeExporter commented 9 years ago
Thank you! I just tried visvis.imread(image), however I got the same error:

File "C:\Python27\lib\site-packages\visvis\vvmovie\images2gif.py", line 436, in 
writeGifToFile
fp.write(globalPalette)
TypeError: must be string or buffer, not list

It seems like it's a problem with writeGif, not how the image was read.

Original comment by Wenzao...@gmail.com on 20 Aug 2013 at 7:09

GoogleCodeExporter commented 9 years ago
I uninstalled Pillow 2.1.0 and installed PIL 1.1.7, and it fixed the problem.

Original comment by Wenzao...@gmail.com on 21 Aug 2013 at 8:04

GoogleCodeExporter commented 9 years ago
Ahah! So probably they changed something in the API causing this problem...

Thanks for that. 

(this code will probably be moved to imageio at some point, where freeimage 
will be used to create the GIF, so I will mark this as not fixed for now)

Original comment by almar.klein@gmail.com on 21 Aug 2013 at 8:11