Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.