Opened 11 years ago

Closed 10 years ago

#2177 closed defect (fixed)

g.gui.animation fail to create gif

Reported by: lucadelu Owned by: grass-dev@…
Priority: normal Milestone: 7.0.0
Component: wxGUI Version: svn-trunk
Keywords: g.gui.animation Cc:
CPU: Unspecified Platform: Unspecified

Description

Hi dev,

today I discovered that g.gui.animation fail to create gif image.

Until few weeks ago it worked really well, the error that we (my colleague told me this problem and I'm able to replicate it) discovered is the following

must be string or buffer, not None

Reason: must be string or buffer, not None

Traceback (most recent call last):
  File "/home/lucadelu/compilati/grass7/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/animation/controller.py", line 554, in _export
    duration=self.timeTick / float(1000), repeat=True)
  File "/home/lucadelu/compilati/grass7/dist.x86_64-unknown-linux-gnu/etc/python/grass/imaging/images2gif.py", line 575, in writeGif
    gifWriter.writeGifToFile(fp, images, duration, loops, xy, dispose)
  File "/home/lucadelu/compilati/grass7/dist.x86_64-unknown-linux-gnu/etc/python/grass/imaging/images2gif.py", line 436, in writeGifToFile
    fp.write(globalPalette)
TypeError: must be string or buffer, not None

Attachments (1)

imaging_gif_export_fix.diff (563 bytes ) - added by neteler 10 years ago.
Suboptimal patch to avoid animated GIF export crash with palette

Download all attachments as: .zip

Change History (14)

comment:1 by annakrat, 11 years ago

I cannot reproduce it. What version of PIL do you have? I assume 1.1.7? Does this happen always or only in some cases? Luca, could you test what you get here? http://trac.osgeo.org/grass/browser/grass/trunk/lib/python/imaging/images2gif.py#L413

Maybe the getheader function returns None?

in reply to:  1 comment:2 by lucadelu, 11 years ago

Replying to annakrat:

I cannot reproduce it. What version of PIL do you have? I assume 1.1.7? Does this happen always or only in some cases? Luca, could you test what you get here? http://trac.osgeo.org/grass/browser/grass/trunk/lib/python/imaging/images2gif.py#L413

Maybe the getheader function returns None?

Yes, it return a list of None values

Something else to test?

comment:3 by annakrat, 11 years ago

It looks like some bug in Pillow. If you uninstall it and use PIL instead, it should work. I am not sure if someone opened a ticket for this for Pillow, I couldn't find anything.

in reply to:  3 ; comment:4 by lucadelu, 11 years ago

Replying to annakrat:

It looks like some bug in Pillow. If you uninstall it and use PIL instead, it should work. I am not sure if someone opened a ticket for this for Pillow, I couldn't find anything.

Are you speaking about python-pillow? Because it is not installed on my computer...

in reply to:  4 comment:5 by annakrat, 11 years ago

Replying to lucadelu:

Replying to annakrat:

It looks like some bug in Pillow. If you uninstall it and use PIL instead, it should work. I am not sure if someone opened a ticket for this for Pillow, I couldn't find anything.

Are you speaking about python-pillow? Because it is not installed on my computer...

I was able to reproduce the error only when I installed Pillow. When I uninstalled it, everything was fine. Also when you google the error message, there has been a lot of people having the same problems recently but I could not find any solution. Anyway, GRASS is not really responsible for this error and I am not sure how can I fix it.

comment:6 by neteler, 11 years ago

I tried on Fedora 20/64bit using the Pillow fix r:

It starts the GIF export, a file of 13 bytes is generated:

file scan2013.gif
scan2013.gif: GIF image data, version 89a, 800 x 497

but it crashes with

must be string or buffer, not None

Reason: must be string or buffer, not None

Traceback (most recent call last):
  File "/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/animation/controller.py", line 554, in _export
    duration=self.timeTick / float(1000), repeat=True)
  File "/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/python/grass/imaging/images2gif.py", line 575, in writeGif
    gifWriter.writeGifToFile(fp, images, duration, loops, xy, dispose)
  File "/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/python/grass/imaging/images2gif.py", line 436, in writeGifToFile
    fp.write(globalPalette)
TypeError: must be string or buffer, not None

The same error as originally reported.

AFAIK Luca uses PIL on Ubuntu while I use python-pillow 2.2.1 on Fedora. Since PIL is no longer developed, Fedora switched to Pillow.

in reply to:  6 comment:7 by neteler, 11 years ago

Replying to neteler:

I tried on Fedora 20/64bit using the Pillow fix r:

Sorry, this one: r58940

in reply to:  6 ; comment:8 by annakrat, 11 years ago

Replying to neteler:

I tried on Fedora 20/64bit using the Pillow fix r:

The same error as originally reported.

AFAIK Luca uses PIL on Ubuntu while I use python-pillow 2.2.1 on Fedora. Since PIL is no longer developed, Fedora switched to Pillow.

Luca, are you sure you don't have Pillow on your computer? I have the same problem only when I install Pillow. When I uninstall it, it's working again. So it looks like it is a Pillow problem.

in reply to:  8 comment:9 by lucadelu, 11 years ago

Replying to annakrat:

Luca, are you sure you don't have Pillow on your computer? I have the same problem only when I install Pillow. When I uninstall it, it's working again. So it looks like it is a Pillow problem.

Sorry Anna, I discovered that python-PIL install python-pillow. So I'm using Pillow, Debian Jessy not provide PIL, we should try to fix this problem or report this bug in Pillow.

comment:10 by neteler, 10 years ago

I still get this error with current relbr7 (r61295 on Fedora 3.14.8-200.fc20.x86_64 with python-pillow-2.2.1-4.fc20.x86_64).

However, I found a partial solution here (patch attached):

http://stackoverflow.com/questions/19149643/error-in-images2gif-py-with-globalpalette

Disadvantage: the background is then black and no more white but at least it stops crashing.

Something more here: http://stackoverflow.com/questions/18325419/error-when-creating-gif-using-images2gif-py

and an apparently slightly updated version here (which contains this bug but other fixes): https://code.google.com/p/visvis/source/browse/vvmovie/images2gif.py

by neteler, 10 years ago

Attachment: imaging_gif_export_fix.diff added

Suboptimal patch to avoid animated GIF export crash with palette

comment:11 by annakrat, 10 years ago

Thanks to this https://github.com/rec/echomesh/blob/master/code/python/external/images2gif.py, I hopefully fixed it in r61417 in trunk. It should work with PIL or Pillow or both installed. Please test.

comment:12 by neteler, 10 years ago

Excellent, the animated GIF export works now in trunk, thanks.

in reply to:  12 comment:13 by annakrat, 10 years ago

Resolution: fixed
Status: newclosed

Replying to neteler:

Excellent, the animated GIF export works now in trunk, thanks.

Tested on Windows and backported in r61427.

Note: See TracTickets for help on using tickets.