Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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$
    -----------------------

  • #2
    Regular Coder
    Join Date
    May 2004
    Location
    sweden
    Posts
    236
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,072
    Thanks
    11
    Thanked 96 Times in 94 Posts
    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)

  • #4
    New to the CF scene
    Join Date
    Feb 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,072
    Thanks
    11
    Thanked 96 Times in 94 Posts
    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)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •