Reputation: 12348
I'm trying to create a GIF file using images2fig.py from the visvis package
With this very simple 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)
I got an error
writeGif(filename, images, duration=0.2)
File "C:\Python27\lib\site-packages\visvis\vvmovie\images2gif.py", line 570, in writeGif
images = gifWriter.convertImagesToPIL(images, dither, nq)
File "C:\Python27\lib\site-packages\visvis\vvmovie\images2gif.py", line 373, in convertImagesToPIL
im = Image.fromarray(im,'RGB')
File "C:\Python27\lib\site-packages\PIL\Image.py", line 1937, in fromarray
obj = obj.tobytes()
AttributeError: 'numpy.ndarray' object has no attribute 'tobytes'
What did I do wrong? How do I fix this?
I'm using Python 2.7.5, PIL 2.0.0-1, numpy 1.7.1-2, all are standard installation from Python(x,y) 2.7.5, and visvis 1.8 which is the latest version.
Upvotes: 4
Views: 1745
Reputation: 365915
This looks like Pillow bug#224.
From what I can tell, the bug was introduced in 2.0.0 and fixed in 2.1.0 (checked in 21 May 2013). So, you should be able to fix it just by upgrading Pillow.
(If you're using a very old version of numpy, or Python 3.x, or a pre-2.0 Pillow (or PIL), this is not your bug. But none of those apply to you.)
Upvotes: 5