PHP: Generating Images On The Fly With PHP |
|
March 18, 2008 |
To generate images on the fly you should do like this:
//image.php
/> $backgroundimage = “matrix.gif”; // this is your background if you need one; it’s in the same directory
$im = //creating the image using the background
$colour = imagecolorallocate($im, 255, 255, 255); //choosing the color of the text
$font = ‘verdanaz’; // choosing the font; you could save your verdanaz.ttf file in the same dir or change this path
$angle = rand(0, 0); // angle
imagettftext($im, 13, $angle, 7, 28, $colour, $font, $str); //positioning the text over the background image
imagepng($im, 0); // save the image as .png in $img_path; you can comment this line
imagepng($im);// show the image
imagedestroy($image); //free the memory ?>
You can use it like this:
…..……



March 18, 2008
Leave a Reply