[GRASS-dev] [GRASS GIS] #2177: g.gui.animation fail to create gif

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------
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
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by 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?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by lucadelu):

Replying to [comment:1 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?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by 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.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by lucadelu):

Replying to [comment:3 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...

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by annakrat):

Replying to [comment:4 lucadelu]:
> Replying to [comment:3 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.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

Hi Anna,

so some feedback here:

I tried in my brain scan location (that's a limited dataset):

GRASS 7.0.svn (markus_brain_ct):~ > g.gui.animation
GRASS 7.0.svn (markus_brain_ct):~ >
GRASS_INFO_MESSAGE(19932,1): ERROR: Unsupported temporal database.
Version mismatch.

GRASS_INFO_MESSAGE(19932,1): Supported temporal database version is: 2

GRASS_INFO_MESSAGE(19932,1): Please remove your old temporal database.

GRASS_INFO_MESSAGE(19932,1): A new one will be created automatically.

GRASS_INFO_MESSAGE(19932,1): Current temporal database info:

GRASS_INFO_MESSAGE(19932,1): DBMI interface:..... sqlite3

GRASS_INFO_MESSAGE(19932,1): Temporal database:..
/home/neteler/grassdata/markus_brain_ct/PERMANENT/tgis/sqlite.db
GRASS_INFO_END(19932,1)
Traceback (most recent call last):
  File "/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/scripts/g.gui.animation",
line 139, in <module>
    GuiModuleMain(main)
  File "/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/core/utils.py",
line 1070, in GuiModuleMain
    mainfn()
  File "/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/scripts/g.gui.animation",
line 129, in main
    frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface())
  File "/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/animation/frame.py",
line 63, in __init__
    tgis.init()
  File "/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/python/grass/temporal/core.py",
line 588, in init
    "info":get_database_info_string()}))
  File "/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/python/grass/pygrass/messages/__init__.py",
line 262, in fatal
    raise FatalError(message)
grass.pygrass.messages.FatalError: Unsupported temporal database.
Version mismatch.
Supported temporal database version is: 2
Please remove your old temporal database.
A new one will be created automatically.
Current temporal database info:
DBMI interface:..... sqlite3
Temporal database:..
/home/neteler/grassdata/markus_brain_ct/PERMANENT/tgis/sqlite.db

I am not scared at all but I feel that it should suggest how to remove
it, in the phrase
"Please remove your old temporal database."

A silly user would do:
g.list db
--> db does not exist

GRASS 7.0.svn (markus_brain_ct):~ > db.tables -p
No tables found

so it is not that obvious how to "reach" the file. I have now simply removed it.

Perhaps also trap the "Version mismatch" with try/except or so?

More I'll add to the ticket.

Markus

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by neteler):

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.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by neteler):

Replying to [comment:6 neteler]:
> I tried on Fedora 20/64bit using the Pillow fix r:

Sorry, this one: r58940

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

On Fri, Feb 7, 2014 at 4:31 PM, Markus Neteler <neteler@osgeo.org> wrote:

Hi Anna,

so some feedback here:

I tried in my brain scan location (that's a limited dataset):

GRASS 7.0.svn (markus_brain_ct):~ > g.gui.animation
GRASS 7.0.svn (markus_brain_ct):~ >
GRASS_INFO_MESSAGE(19932,1): ERROR: Unsupported temporal database.
Version mismatch.

GRASS_INFO_MESSAGE(19932,1): Supported temporal database version is: 2

GRASS_INFO_MESSAGE(19932,1): Please remove your old temporal database.

GRASS_INFO_MESSAGE(19932,1): A new one will be created automatically.

GRASS_INFO_MESSAGE(19932,1): Current temporal database info:

GRASS_INFO_MESSAGE(19932,1): DBMI interface:..... sqlite3

GRASS_INFO_MESSAGE(19932,1): Temporal database:..
/home/neteler/grassdata/markus_brain_ct/PERMANENT/tgis/sqlite.db
GRASS_INFO_END(19932,1)
Traceback (most recent call last):
  File
"/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/scripts/g.gui.animation",
line 139, in <module>
    GuiModuleMain(main)
  File
"/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/core/utils.py",
line 1070, in GuiModuleMain
    mainfn()
  File
"/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/scripts/g.gui.animation",
line 129, in main
    frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface())
  File
"/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/animation/frame.py",
line 63, in __init__
    tgis.init()
  File
"/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/python/grass/temporal/core.py",
line 588, in init
    "info":get_database_info_string()}))
  File
"/home/neteler/software/grass70/dist.x86_64-unknown-linux-gnu/etc/python/grass/pygrass/messages/__init__.py",
line 262, in fatal
    raise FatalError(message)
grass.pygrass.messages.FatalError: Unsupported temporal database.
Version mismatch.
Supported temporal database version is: 2
Please remove your old temporal database.
A new one will be created automatically.
Current temporal database info:
DBMI interface:..... sqlite3
Temporal database:..
/home/neteler/grassdata/markus_brain_ct/PERMANENT/tgis/sqlite.db

I am not scared at all but I feel that it should suggest how to remove
it, in the phrase
"Please remove your old temporal database."

A silly user would do:
g.list db
--> db does not exist

GRASS 7.0.svn (markus_brain_ct):~ > db.tables -p
No tables found

so it is not that obvious how to "reach" the file. I have now simply
removed it.

Perhaps also trap the "Version mismatch" with try/except or so?

Not sure if try/except and then GUI window is needed. More important is the
content of the message. Not only that it does gives suggestion what to do
but it is misleading since it is silent about the fact that simple removal
(which is suggested) will lead to the data loss.

In #2158, I say:

Sentences `Please remove your old temporal database. A new one will be
created automatically.` could seem that you just remove the old file and
the new one will be created. It isn't that simple, you will loose your
temporal data. This detail should be mentioned in the message.

Shouldn't the message say something like `Please backup and then remove
your old temporal database.`? Maybe with some suggestion how to backup. Or
do you have some other idea, how to deal with this?

http://trac.osgeo.org/grass/ticket/2158#comment:7

Vaclav

More I'll add to the ticket.

Markus
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by annakrat):

Replying to [comment:6 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.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by lucadelu):

Replying to [comment:8 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.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by neteler):

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

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by annakrat):

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.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:11&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
-----------------------------+----------------------------------------------
Reporter: lucadelu | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | Platform: Unspecified
      Cpu: Unspecified |
-----------------------------+----------------------------------------------

Comment(by neteler):

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

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:12&gt;
GRASS GIS <http://grass.osgeo.org>

#2177: g.gui.animation fail to create gif
--------------------------+-------------------------------------------------
  Reporter: lucadelu | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: g.gui.animation
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by annakrat):

  * status: new => closed
  * resolution: => fixed

Comment:

Replying to [comment:12 neteler]:
> Excellent, the animated GIF export works now in trunk, thanks.
Tested on Windows and backported in r61427.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2177#comment:13&gt;
GRASS GIS <http://grass.osgeo.org>