This tutorial would help you to convert a string to image using php. I have named the function as text2image as it makes some sense.
The main functions used in the following function is
1. imagecreate
2. imagecolorallocate
3. imagecolorallocate
4. imagestring
5. imagepng
[php]
function text2image($string) {
// create a 100*30 image
$im = imagecreate(197, 30);
// black background and white text
$bg = imagecolorallocate($im, 0, 0, 0);
$textcolor = imagecolorallocate($im, 255, 255, 255);
// write the string
imagestring($im, 5, 10, 5, $string, $textcolor);
// output the image
header("Content-type: image/png");
return imagepng($im);
}
echo text2image(‘http://www.infoplotter.com’);
[/php]
Hope it helped you !
- Tags: php