Problem with exec()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gsoper
Forum Newbie
Posts: 1
Joined: Sat Jun 05, 2004 8:13 am

Problem with exec()

Post 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$
-----------------------
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

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