Error creating GIF using image2gif.py

I am 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 message

  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 I did wrong? How to fix it?

I use Python 2.7.5, PIL 2.0.0-1, numpy 1.7.1-2, all this is a standard installation from Python (x, y) 2.7.5 and visvis 1.8, which is the latest version.

+4
source share
1 answer

It looks like Pillow Error # 224 .

From what I can tell, the error was introduced in 2.0.0 and fixed in 2.1.0 ( checked on May 21, 2013 ). That way, you can fix it just by updating your pillow.

(If you are using a very old version of numpy or Python 3.x or a pillow before 2.0 (or PIL), this is not your fault. But none of them apply to you.)

+5
source

Source: https://habr.com/ru/post/1497893/


All Articles