[problem]
You want to generate an image, with text over the top.
[/problem]
[solution]
Why of course we use PHP extensive image library routines! 🙂
[/solution]
[example]
<?php
header(“Content-type: image/png”);
$string = $_GET[‘label’];
if(isset($_GET[‘font’])) { $font = $_GET[‘font’]; } else { $font=“2″; }
$len=strlen($string);
$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);
imagepng($im);
imagedestroy($im);
?>
[/example]
[reference]
I’ve now created an online tool, using this code Label Your Images
[tags]Image Creation, Label Image, PHP Coding School[/tags]
[/reference]
If you have found my website useful, please consider buying me a coffee below 😉