Return codes in shell/php

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Return codes in shell/php

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Return codes in shell/php

Post 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.
Post Reply