View Full Version : Embed PHP into a image.

06-17-2006, 06:17 PM
How would i embed PHP into images.

Examples like this (http://www.legendarygamers.net/StatSig3.php).

Ive made the image, but i would like to embed some stats into it.

All help is appreciated. THanks alot!!!

06-17-2006, 06:26 PM
Firstly, you embed images into php not visa versa. You must pass headers to the browser, telling it that the php page is an image e.g.

Header ("Content-type: image/jpeg");

You can then use the ImageString function (look on php.net) to write text over an image.


06-17-2006, 07:14 PM
o ok thanks alot.

ill look it up.

can i use this?

// create a 100*30 image
$im = imagecreate(100, 30);

// white background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// write the string at the top left
imagestring($im, 5, 0, 0, "Hello world!", $textcolor);

// output the image
header("Content-type: image/jpeg");

06-17-2006, 10:23 PM
I dont know to work with gd but your code seems to work...

07-13-2006, 03:39 PM
I was wondering if it is possible to embed a link into this image. I read about it somewhere with gd lib but cant seem to find it?

Basically i want to share this dynamic image but have link back to my site built into it.

Any Ideas?