amit_n Posted April 9, 2009 Share Posted April 9, 2009 Hi, I am trying to create a image. I am using WAMP and PHPinfo show GD is included. I have following code but i am not able to see the image. It displays the placeholder. Code for picture1.php <?php $image = imagecreate(400,300); // do stuff to the image imagejpeg($image, '', 75); imagedestroy($image); ?> Code for phppicture.html <HTML> <TITLE>PHP Art</TITLE> <BODY> PHP woz 'ere: <img src="picture1.php" /> </BODY> </HTML> Please help me with this problem. Thanks Quote Link to comment Share on other sites More sharing options...
en Posted April 9, 2009 Share Posted April 9, 2009 I guess you need something like this: header("Content-type: image/jpeg"); Imagejpeg($image); ImageDestroy($image); // Free memory Quote Link to comment Share on other sites More sharing options...
amit_n Posted April 9, 2009 Author Share Posted April 9, 2009 It is still showing me red X. Quote Link to comment Share on other sites More sharing options...
Axeia Posted April 9, 2009 Share Posted April 9, 2009 I suggest taking a look at the PHP imagejpeg documentation page, copy/paste examples are provided, like this one: <?php // Create a blank image and add some text $im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); // Set the content type header - in this case image/jpeg header('Content-type: image/jpeg'); // Output the image imagejpeg($im); // Free up memory imagedestroy($im); ?> As you modify it and it stops displaying (not even an error) then comment the line header('Content-type: image/jpeg'); like this: //header('Content-type: image/jpeg'); And errors should show up. As soon as you fixed the errors and the only output you're getting looks like gibberish, then uncomment the header line again and you should see the image again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.