Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Thursday, January 10, 2008

PHP can make images

Here is an example of making images with php.


// create a 100*30 image
$im = imagecreate(100, 30);
$im = imagecreatefromjpeg("http://www.example.com/image.jpg"); /* Attempt to open */
// 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, 4, 375, 0, "Valid from: " . date("n\/j\/y") . " to " . date("n\/j\/y",mktime() + (7*60*60*24)), $textcolor);

// output the image
header("Content-type: image/jpeg");
imagejpeg($im);
?>