Jump to content

GD Help


thecase

Recommended Posts

Code I found around the web

 

header("Content-Type: image/jpeg");


$im = ImageCreateFromGif("images/crimbo.gif"); 


$black = ImageColorAllocate($im, 255, 255, 255);


$start_x = 10;
$start_y = 20;


Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'verdana.ttf', "test text");


Imagejpeg($im, '', 100);

ImageDestroy($im);

Link to comment
https://forums.phpfreaks.com/topic/219248-gd-help/#findComment-1136971
Share on other sites

soo...did you actually look at your code and research what it is actually doing? Just as I suspected, you are outputting a raw image as a response (making a call with header() to tell the browser the data is raw image data) and then in Imagejpeg() you are outputting the raw image data instead of saving it to a file.  So what happens is when you make a request to the server for that script, it will respond with a raw image.

 

So how are you trying to call this script for the rest of your site? Because as it stands now, you can do something like

 

<img src='path/to/your/script.php' width='100' height='100' />

 

and your script will generate and return the image to be used in a normal html tag.

Link to comment
https://forums.phpfreaks.com/topic/219248-gd-help/#findComment-1136979
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.