View Full Version : images and php

07-22-2007, 12:14 AM

I have an image using the:

<img src="">

standard image html notation. How would I create an image that displayed text echoed using php. For example I would like the result of:

echo "hello world"

to be displayed on my image??


07-22-2007, 12:17 AM

07-22-2007, 12:32 AM
I found this code on a website to write a string on an image. Is there a PHP function which accepts parameters such as picture.jpg instead of values as with "imagecreate(100, 30)" or another way to use an image i have created in photoshop. The way you suggested i didnt think gave much control over the look of the button for a novice.

// 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/png");