Page 1 of 1

Is it possible for convert to return a "-1" ?

Posted: 2011-05-26T21:00:08-07:00
by xnooby
Is it possible for convert to return a "-1" ?

A friend of mine is using Cygwin's 6.4.0 version of ImageMagick to run the convert program, and apparently receives a "-1" return code from convert.

After some searching, it appears the ImageMagick programs only return a 0 (success) or a 1 (failure). So I am guessing his "-1" return code is coming from the Windows OS or the Windows convert.exe program. I could not find anything in google about a negative return code from ImageMagick, though I did see some Exception codes listed that had values greater than 1.

Is it correct to say that convert itself only returns a 0 or 1?


What I found so far:

http://www.imagemagick.org/script/exception.php
viewtopic.php?f=3&t=12115
viewtopic.php?f=1&t=8571&start=0

Re: Is it possible for convert to return a "-1" ?

Posted: 2011-05-26T23:39:11-07:00
by anthony
There should not be any such return code period.

this is nothing to do with Image Magick but UNIX command line handling. Return codes are purely a number from 0 to 255. However on top of this the Exec System Library Call adds another 8 bit code above that whcih defines interupt or crash codes from programs.

As such a caller may get a 16 bit return value of #FFFF, and a BAD shell may report that as being a value of -1.

It is NOT -1. It is a value of 65535 or a interupted command with a return code of 255.


Basically -1 is a nonsense return from a bad shell on a program that crashed in some way. At least under UNIX.

What it means under DOS I have no idea! but it is either a bad thing or something to just ignore.

Re: Is it possible for convert to return a "-1" ?

Posted: 2011-05-27T06:16:11-07:00
by xnooby
When ImageMagick has an error, say convert is called with a non-existent file as input, does it display a message saying what the error is, and then return a "1" ?

Re: Is it possible for convert to return a "-1" ?

Posted: 2011-05-27T09:39:09-07:00
by fmw42
don't know if this is what you want, but see -regard-warnings at http://www.imagemagick.org/Usage/basics/#controls

Re: Is it possible for convert to return a "-1" ?

Posted: 2011-05-28T10:10:10-07:00
by xnooby
Thanks, we will try using "convert -quiet -regard-warnings...". When I googled -regard-warnings, it seems it is generally used with "-quiet", so we will try them together.

Or are you suggesting just use the "-regard-warnings" ?

Re: Is it possible for convert to return a "-1" ?

Posted: 2011-05-28T12:44:13-07:00
by fmw42
if you want to see the error message, leave off -quiet; otherwise if you include it is suppresses the actual error and you can then create you own message, such as

convert -quiet -regard-warnings "$infile" +repage $dir/tmpI.mpc ||
echo "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"

see the link above provided earlier