Jump to content

Creating an image


amit_n

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/153312-creating-an-image/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/153312-creating-an-image/#findComment-805456
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.