prabodh - 2012-07-24 09:57:02
<?php
header("Content-type: image/jpeg");
$text = "
<h1>Here goes content</h1>
";
$padding = 10; #10px
$fsize = 12; #font size 12 pixels
$ttf ="./verdana.ttf"; #path to windows ttf font file
$size = imagettfbbox($fsize, 0, $ttf, $text);
$xsize = abs($size[0]) + abs($size[2])+($padding*2);
$ysize = abs($size[5]) + abs($size[1])+($padding*2);
$image = imagecreate($xsize, $ysize);
$white = imagecolorallocate ($image, 255, 255, 255);
$black = imagecolorallocate ($image, 0, 0, 0);
imagefilledrectangle ($image, 0, 0, $xsize, $ysize, $white);
$text_color = imagecolorallocate($image, 233, 14, 91);
imagettftext($image, $fsize, 0, $padding, $fsize+$padding, $black, $ttf, $text);
imagestring($image, 1, 5, 5, "<h2>A Simple Text String</h2>", $text_color);
imagejpeg($image,"./screenshot.gif",85); #85%quality
?>
I want to convert html to image. i have above code. but when i run above code it display error: the image cannot display because it contain error.
anybody can help me to debug this code.