Generate images with PHP and GD
Create images on the fly with PHP and GD.
<?php
/*
* Create an image with text with PHP and GD
*/
header("content-type: image/png");
// Here we create the image met X=200 en Y=50
$image = ImageCreate(200, 50);
// Set the background color of the image
$background = ImageColorAllocate($image, 255, 255, 255); //255, 255, 255 = White
// Set the fontsize
$size = 5;
//Text we want on the image
$text = 'Scriptary.com';
//Set the fontcolor
$color = ImageColorAllocate($image, 255, 0, 0); //255, 0, 0 = Red
//Puts the string on the image
ImageString($image, $size, 5, 25, $text, $color);
//Create the image
ImagePng($image);
//Remove image from memory
ImageDestroy($image);
?>
|
|
Description
Basic example how to generate images with PHP and GD. Copy paste this code to a new .php file and run it from the browser
Top