Home  • Programming • PHP

Create an image on the fly with the PHP GD library

We already know how to return an already made image; here's how to create an image on the fly:
<?php
header ("Content-type: image/png");
$im = @imagecreate (150, 50)
   or die ("Couldn't create image!");
$background_color = imagecolorallocate ($im, 205, 205, 255);
$text_color = imagecolorallocate ($im, 233, 14, 91);
imagestring ($im, 2, 5, 5,  "A Simple Text String", $text_color);
imagepng ($im);
imagedestroy($im);
?> 

Comments 6


Copyright © 2026. Powered by Intellect Software Ltd