Page 1 of 1

Problem with exec()

Posted: Sat Jun 05, 2004 8:13 am
by gsoper
I'm using ImageMagic under UNIX via the exec() function. I'm using it to
ascertain the dimension of JPEGs. The code which is causing problems is
below, I've used debugging code to try and work out what is going on with
the results as shown in a browser. I've then taken what appears to be sent
to the exec() function and copied it straight into a termal on the same
machine. When running in PHP the $exec_output array seems to be empty but on
the terminal I'm getting output. Can anyone suggest why this might be so?

Thanks,
Geoff Soper

-----------------------
Code:
<snip>
$identify_cmd = "/home/<username>/ImageMagick/bin/identify -format
\"%w:%h\" \"JPEG:$input_path\"[0]";
<snip>
exec ($identify_cmd, $exec_output);
echo "identify_cmd = $identify_cmd<br>";
echo 'exec_output = ';
print_r($exec_output);
echo '<br>';
list($input_width, $input_height) = split(":", $exec_output[0]);
echo "input_width = $input_width<br>";
echo "input_height = $input_height<br>";
exit;
-----------------------

-----------------------
Browser:
identify_cmd = /home/<username>/ImageMagick/bin/identify -format "%w:%h"
"JPEG:<path>/Panorama 3.jpg"[0]
exec_output = Array ( )
input_width =
input_height =
-----------------------

-----------------------
Terminal:
bash-2.05a$ /home/<username>/ImageMagick/bin/identify -format "%w:%h"
"JPEG:<path>/Panorama 3.jpg"[0]
6217:2604

bash-2.05a$
-----------------------

Posted: Sat Jun 05, 2004 9:03 am
by feyd
exec doesn't look like it's disabled, although, if you preset $exec_output to a blank array, then it's possible. Other than that, if GD isn't disabled on the server, you could use [php_man]getimagesize[/php_man](). IIRC, offsets 1 and 2 are width and height, respectively.