Opened 7 years ago
Closed 7 years ago
#3367 closed defect (fixed)
g.gui.animation: animated GIF export generates corrupted GIF files
Reported by: | neteler | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.2.2 |
Component: | wxGUI | Version: | svn-releasebranch72 |
Keywords: | g.gui.animation | Cc: | |
CPU: | x86-64 | Platform: | Linux |
Description
When exporting an animated GIF, the generated file is corrupted:
# using GRASS 7.2.2svn (nc_climate_spm_2000_2012): > g.region raster=2002_10_precip -p g.gui.animation `g.list raster pattern="2*_10_precip" sep=comma` Default TGIS driver / database set to: driver: sqlite database: $GISDBASE/$LOCATION_NAME/$MAPSET/tgis/sqlite.db WARNING: Temporal database connection defined as: /home/mneteler/grassdata/nc_climate_spm_2000_2012/climate_1970_2012/tgis/sqlite.db But database file does not exist. Creating temporal database: /home/mneteler/grassdata/nc_climate_spm_2000_2012/climate_1970_2012/tgis/sqlite.db /home/mneteler/software/grass72/dist.x86_64-pc-linux-gnu/etc/python/grass/imaging/images2gif.py:344: VisibleDeprecationWarning: converting an array with ndim > 0 to an index will result in an error in the future im2 = im[y0:y1, x0:x1]
(not sure if the warning matters)
ls -la bla.gif -rw-r--r-- 1 mneteler mneteler 1561325 Jul 6 14:55 bla.gif display bla.gif display: corrupt image `bla.gif' @ error/gif.c/ReadGIFImage/1368.
System:
System Info GRASS version: 7.2.2svn GRASS SVN revision: r71233M Build date: 2017-07-03 Build platform: x86_64-pc-linux-gnu GDAL: 2.1.2 PROJ.4: 4.9.2 GEOS: 3.5.0 SQLite: 3.14.2 Python: 2.7.13 wxPython: 3.0.2.0 Platform: Linux-4.11.3-202.fc25.x86_64-x86_64-with-fedora-25-Twenty_Five
Attachments (1)
Change History (23)
comment:1 by , 7 years ago
CPU: | Unspecified → x86-64 |
---|---|
Platform: | Unspecified → Linux |
Version: | unspecified → svn-releasebranch72 |
comment:2 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
follow-ups: 4 5 comment:3 by , 7 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
It automatically closed it, please test and I will backport it then.
comment:4 by , 7 years ago
Replying to annakrat:
It automatically closed it, please test and I will backport it then.
After updating (make distclean ; svn up && sh config_grass7.sh && make), I still get a corrupted gif from g.gui.animation.
display prueba.gif display: corrupt image `prueba.gif' @ error/gif.c/ReadGIFImage/1368.
System Info
GRASS version: 7.3.svn GRASS SVN revision: r71243M Build date: 2017-07-08 Build platform: x86_64-pc-linux-gnu GDAL: 2.1.2 PROJ.4: 4.9.2 GEOS: 3.5.0 SQLite: 3.14.2 Python: 2.7.13 wxPython: 3.0.2.0 Platform: Linux-4.11.8-200.fc25.x86_64-x86_64-with-fedora-25-Twenty_Five
comment:5 by , 7 years ago
Replying to annakrat:
It automatically closed it, please test and I will backport it then.
tested here with
GRASS version: 7.3.svn GRASS SVN revision: r71243 Build date: 2017-07-08 Build platform: x86_64-pc-linux-gnu GDAL: 2.2.0 PROJ.4: 4.9.3 GEOS: 3.5.1 SQLite: 3.16.2 Python: 2.7.13 wxPython: 3.0.2.0 Platform: Linux-4.9.0-3-amd64-x86_64-with-debian-9.0
display gguitest2.gif display-im6.q16: corrupt image `gguitest2.gif' @ error/gif.c/ReadGIFImage/1386.
follow-ups: 7 8 comment:6 by , 7 years ago
My gifs are ok... Could you test this code snippet to see if the problem is in the images2gif (likely)? Also do you have Pillow or PIL?
import os from PIL import Image from grass.imaging import writeGif color_path = os.path.join(os.environ['GISBASE'], "docs", "html", "colortables") pil_images = [Image.open(os.path.join(color_path, c)) for c in os.listdir(color_path)] writeGif('/tmp/test.gif', pil_images, duration=0.2, repeat=True)
comment:7 by , 7 years ago
Replying to annakrat:
My gifs are ok... Could you test this code snippet to see if the problem is in the images2gif (likely)? Also do you have Pillow or PIL?
import os from PIL import Image from grass.imaging import writeGif color_path = os.path.join(os.environ['GISBASE'], "docs", "html", "colortables") pil_images = [Image.open(os.path.join(color_path, c)) for c in os.listdir(color_path)] writeGif('/tmp/test.gif', pil_images, duration=0.2, repeat=True)
lines above tested
display test.gif display-im6.q16: corrupt image `test.gif' @ error/gif.c/ReadGIFImage/1386.
the same error
comment:9 by , 7 years ago
I tested the code in the python console of GRASS GUI. The output gif gives the same error as before.
I have python2-pillow-3.4.2-1
follow-ups: 11 12 comment:10 by , 7 years ago
Could you test any of the available versions of images2gif.py files from different repositories? I found couple for example:
https://github.com/isaacgerg/images2gif/blob/master/images2gif.py
https://gist.github.com/jonschoning/7216290
https://github.com/rec/echomesh/blob/master/code/python/external/images2gif.py
If you replace the import with
from images2gif import writeGif
then the test code snippet should work.
comment:11 by , 7 years ago
Replying to annakrat:
Could you test any of the available versions of images2gif.py files from different repositories? I found couple for example:
https://github.com/isaacgerg/images2gif/blob/master/images2gif.py
https://gist.github.com/jonschoning/7216290
https://github.com/rec/echomesh/blob/master/code/python/external/images2gif.py
If you replace the import with
from images2gif import writeGif
then the test code snippet should work.
tested here with
System Info GRASS version: 7.3.svn GRASS SVN revision: r71251 Build date: 2017-07-09 Build platform: x86_64-w64-mingw32 GDAL: 2.2.1 PROJ.4: 4.9.3 GEOS: 3.5.0 SQLite: 3.17.0 Python: 2.7.5 wxPython: 2.8.12.1 Platform: Windows-8-6.2.9200 (OSGeo4W)
and no change in images2gif.
the gif is exported, but it's not displayed correctly. only the first frame is shown and the next frames are white
comment:12 by , 7 years ago
Replying to annakrat:
Could you test any of the available versions of images2gif.py files from different repositories? I found couple for example:
https://github.com/isaacgerg/images2gif/blob/master/images2gif.py
https://gist.github.com/jonschoning/7216290
https://github.com/rec/echomesh/blob/master/code/python/external/images2gif.py
tested here on windows all these images2gif.py, none of them worked.
comment:13 by , 7 years ago
I tested it on standalone winGRASS and OSGEO4W and it works in the standalone one, but not in OSGEO4W. It seems they use different PIL library, so that must be the difference. I will look into it later.
comment:15 by , 7 years ago
So, after some digging around, it seems to stop working since Pillow version 3.4.0 and I haven't found anywhere a working version of images2gif.py and I haven't been able to find the problem. But since 3.4.0 Pillow itself allows to write GIFs, so I added it there. Now depending on your PIL/Pillow and Pillow version, either the old or the native Pillow way is used. The problem is the GIF created by Pillow looks worse, but I don't know what could be done here. Also we could use imagemagick as a backend if it's installed and available. Anyway, please test.
follow-up: 17 comment:16 by , 7 years ago
Tested here having python2-pillow-3.4.2-1. Now, it works, but as you say the GIF doesn't look so good in terms of definition of the images. They look noisy, as when you increase ISO in the camera.
follow-up: 20 comment:17 by , 7 years ago
Replying to veroandreo:
Tested here having python2-pillow-3.4.2-1. Now, it works, but as you say the GIF doesn't look so good in terms of definition of the images. They look noisy, as when you increase ISO in the camera.
I can confirm it. I have python-pil 4.2.1-1
. See attachment:noisy.gif created by
import os from PIL import Image from grass.imaging import writeGif color_path = os.path.join(os.environ['GISBASE'], "docs", "html", "colortables") pil_images = [Image.open(os.path.join(color_path, c)) for c in os.listdir(color_path)] writeGif('/tmp/test.gif', pil_images, duration=0.2, repeat=True)
by , 7 years ago
follow-up: 21 comment:20 by , 7 years ago
Replying to martinl:
Replying to veroandreo:
Tested here having python2-pillow-3.4.2-1. Now, it works, but as you say the GIF doesn't look so good in terms of definition of the images. They look noisy, as when you increase ISO in the camera.
I can confirm it. I have
python-pil 4.2.1-1
. See attachment:noisy.gif created byimport os from PIL import Image from grass.imaging import writeGif color_path = os.path.join(os.environ['GISBASE'], "docs", "html", "colortables") pil_images = [Image.open(os.path.join(color_path, c)) for c in os.listdir(color_path)] writeGif('/tmp/test.gif', pil_images, duration=0.2, repeat=True)
Could you test r71485? I used quantize function and it seems better.
In 71243: