Page 1 of 1

Return codes in shell/php

Posted: 2007-03-02T12:50:17-07:00
by Bonzo
I know this is not really an ImageMagick problem but I have started looking at the "return code" from the code.

Is there a list anywhere telling you what they mean ? Or do they not tell you anything useful apart from 0 succesful and everything else fail ?

e.g.

Code: Select all

exec("/usr/local/bin/convert /( bluetest.jpg -blend 88 -gravity northeast header.jpg -matte -composite /) -resize 600x -crop 600x127+0+10 temp1.jpg", $output, $return);
// Returns 2 - A fail

exec("/usr/local/bin/convert -size 640x480 temp.jpg -resize 600x -crop 600x127+0+10 new_header.jpg", $output, $return);
// Returns 1 - Another fail ( I know in this case the temp.jpg image does not exist )

exec("/usr/local/bin/convert -size 640x480 header.jpg -resize 600x -crop 600x127+0+10 new_header.jpg", $output, $return);
// Returns 0 - Succesful image generation

Re: Return codes in shell/php

Posted: 2007-03-02T14:02:45-07:00
by magick
ImageMagick program return codes are 0 for success and 1 for failure. We thought about other status codes but there was no easy way to map the ImageMagick errors and warnings to status codes. For one, there are only 127 bits to work with but the community discourages use above 64.. A number of codes are defacto reserved in the 1-64 range for particular errors and in general using codes other than 0 and 1 is generally discouraged in the programming community.