Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-05-2004, 02:11 PM   PM User | #1
gsoper
New to the CF scene

 
Join Date: Feb 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
gsoper is an unknown quantity at this point
Problem with exec()

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$
-----------------------
gsoper is offline   Reply With Quote
Old 06-05-2004, 03:13 PM   PM User | #2
carl_mcdade
Regular Coder

 
Join Date: May 2004
Location: sweden
Posts: 236
Thanks: 0
Thanked 0 Times in 0 Posts
carl_mcdade is an unknown quantity at this point
It's too confusing to see just what you are trying to do. The page that has the code that is supposed to be executed is?
__________________
Carl McDade
_____________
Hiveminds Magazine
for web publisher and community builders
eRuby Tutorials
carl_mcdade is offline   Reply With Quote
Old 06-06-2004, 10:39 AM   PM User | #3
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,904
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
not the answer to your question but why not use getimagesize('/path/to/image') ? it works with or without GD support.

as for image magick , if it works in the terminal it should work via the browser , but if you are getting path related errors (apache/your host may be doing some path translation) try redirecting errors back to PHP and see if they tell you anything .....

PHP Code:
<?
 exec 
($identify_cmd ' 2>&1 '$exec_output);
?>
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 06-06-2004, 01:23 PM   PM User | #4
gsoper
New to the CF scene

 
Join Date: Feb 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
gsoper is an unknown quantity at this point
Brilliant, that meant I was able to discover it was a memory problem, now I just need to sort that out!

Could you point me in the direction what that cryptic "2>&1" actually does?

Thanks,
Geoff
gsoper is offline   Reply With Quote
Old 06-07-2004, 03:26 AM   PM User | #5
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,904
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
Hi, I am not a shell guru , but basically it redirects errors (stderr) to stdout, in your case PHP , more info @ ..
http://www.tldp.org/LDP/abs/html/ioredirintro.html
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:18 AM.


Advertisement
Log in to turn off these ads.