I am using Version: ImageMagick 6.9.3-7 Q16 x86_64 2016-04-03
When I attempt to use convert to extract frames for a gif sometimes i get this with corrupt gifs:
convert -coalesce examine.gif video.png
convert: corrupt image `examine.gif' @ error/gif.c/ReadGIFImage/1368.
convert: no images defined `video.png' @ error/convert.c/ConvertImageCommand/3252.
Here is a link to an example image that chokes here:
http://www.image-share.com/upload/3207/277.gif
When I execute it from a subprocess in python - I can't seem to catch the error output:
command = ["convert" , "-coalesce", "-scene" , str(file_counter) , infile, outfile]
output,error = subprocess.Popen(command, universal_newlines=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=r'/home/mvgen/fixgifs').communicate()
Output and Error are generally blank or say NONE.
Anyone have some hints for a work around like this with broken gifs? Identify will give a frame count from even corrupt gifs.
Error with extracting gif frames, and catching the error in python
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Error with extracting gif frames, and catching the error in python
Proper IM 6 syntax has the -coalesce after reading the input image. Nevertheless, if the image is corrupt, IM will give an error message. I am not sure why IM says it is corrupt, since it plays fine in a browser.
I do not know Windows and you do not say what platform your are on, but in Unix, you can tell if there is an error by looking at the error code. 0 means success and 1 means failure.
Using null: to avoid writing any output, just for testing if an error.
convert: corrupt image `277.gif' @ error/gif.c/ReadGIFImage/1368.
convert: no images defined `null:' @ error/convert.c/ConvertImageCommand/3252.
1
Or
convert: corrupt image `277.gif' @ error/gif.c/ReadGIFImage/1368.
convert: no images defined `null:' @ error/convert.c/ConvertImageCommand/3252.
error
Sorry I do not know Python and from a subprocess, you may have to send the result to 2>&1
I do not know Windows and you do not say what platform your are on, but in Unix, you can tell if there is an error by looking at the error code. 0 means success and 1 means failure.
Using null: to avoid writing any output, just for testing if an error.
Code: Select all
convert 277.gif -coalesce null:
convert: no images defined `null:' @ error/convert.c/ConvertImageCommand/3252.
Code: Select all
echo "$?"
Or
Code: Select all
convert 277.gif -coalesce null: || echo "error"
convert: no images defined `null:' @ error/convert.c/ConvertImageCommand/3252.
error
Sorry I do not know Python and from a subprocess, you may have to send the result to 2>&1
Code: Select all
convert 277.gif -coalesce null: 2>&1 || echo "error"