display an image with a label superimposed


You want to generate an image, with text over the top.



Why of course we use PHP extensive image library routines! 🙂




header(“Content-type: image/png”);
$string = $_GET[‘label’];

if(isset($_GET[‘font’])) { $font = $_GET[‘font’]; } else { $font=“2″; }
$text_width = imagefontwidth($font);
$text_height = imagefontwidth($font);
/* Create a blank image */
$im = imagecreate (($len*$text_width)+10, $text_height+10);
$bgc = imagecolorallocate ($im, 0, 0, 0);
$tc = imagecolorallocate ($im, 255, 255, 255);
imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
imagestring ($im, $font, 5, 0, “$string”, $tc);




I’ve now created an online tool, using this code Label Your Images

[tags]Image Creation, Label Image, PHP Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *