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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2008
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    can't create simple image from php exec , can create with the same command standalone

    I have this code running in CentOS 5.5 ,PHP 5.1.6 ,Apache/2.2.3 ,ImageMagick 6.2.8
    PHP Code:
    $convert "/usr/bin/convert";
    $command "$convert -size 100x100 xc:blue mytest.jpg";
    $test_image exec($command);
    echo 
    "<img src=\"mytest.jpg\">"
    when i run the php tester i dont get the image created , only the echo string printed on page as html.
    but when i run the same command as onliner the image does created just fine.
    PHP Code:
    /usr/bin/convert -size 100x100 xc:blue mytest.jpg 
    what is wrong here i can't tell.

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Enable error_reporting and see what error message you get. Personally, I'm guessing user:group permissions.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    The description for the problem actually sounds like its being served as text/plain.
    At the top of your page, try adding an html header:
    PHP Code:
    header("Content-type: text/html"); 
    I assumed that your output was:
    Code:
    <img src="mytest.jpg" />
    and not
    Code:
    echo "<img src=\"mytest.jpg\" />";
    right?

    Also, be warned that exec() is often disabled for security reasons. If it is, you can use the PHP GD Library to alter your graphics.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #4
    Regular Coder
    Join Date
    Jan 2008
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    the image dosn't created

    before the html


  •  

    Posting Permissions

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