Calling convert from PHP, how to get return code?
Posted: 2013-12-08T13:06:26-07:00
Hi,
I am calling the convert command line program from PHP with the following command:
exec( $cmd, $output = array(), $return_var );
$cmd has the full command line, e. g.:
/usr/bin/convert "photos_gallery/2010-01-05_Myanmar/RP_2010-01-09_0920_01_thumb.jpg" -write temp/307_thumb_h240.icc -resize x240 -unsharp 1x2+1+0.1 -quality 80 -strip -profile temp/307_thumb_h240.icc "photos_cache/307_thumb_h240.jpg"
Now if something is wrong, then $return_var is always 1, regardless of what error or warning ImageMagick got.
Is there any way to get from PHP the real error/warning code?
My problem is that it seems I get a warning, the $return_val is 1 but the output file is actually there. I'd like to find out what is wrong but I do not have command line access to my hosting server. I also cannot reproduce the issue locally.
Cheers, Robert
I am calling the convert command line program from PHP with the following command:
exec( $cmd, $output = array(), $return_var );
$cmd has the full command line, e. g.:
/usr/bin/convert "photos_gallery/2010-01-05_Myanmar/RP_2010-01-09_0920_01_thumb.jpg" -write temp/307_thumb_h240.icc -resize x240 -unsharp 1x2+1+0.1 -quality 80 -strip -profile temp/307_thumb_h240.icc "photos_cache/307_thumb_h240.jpg"
Now if something is wrong, then $return_var is always 1, regardless of what error or warning ImageMagick got.
Is there any way to get from PHP the real error/warning code?
My problem is that it seems I get a warning, the $return_val is 1 but the output file is actually there. I'd like to find out what is wrong but I do not have command line access to my hosting server. I also cannot reproduce the issue locally.
Cheers, Robert