I have a JPEG image that has been dynamically created and I'm trying to add anti-aliased (without jagged edges) text to it. I don't seem to be able to do so. I installed a patch at http://www.coupin.net/gd-freetype/ but it didn't seem to change anything.
here is my sourcecode
(At present the thumbnail and the original are the same size. Don't let that confuse you...):
<?PHP
// FOLLOWING IS THE SOURCE CODE TO CREATE A THUMBNAIL IMAGE
//----------------------------------------------------------
function createthumb($name,$filename,$new_w,$new_h) {
// GET RESOURCE ID OF ORIGINAL (BIG) IMAGE:
$src_img=ImageCreateFromJPEG($name);
// FIND SIZES OF ORIGINAL (BIG) IMAGE:
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
// CREATE A BLANK IMAGE (AND RESOURCE ID) OF THE APPROPRIATE THUMBNAIL SIZE:
$dst_img=ImageCreateTrueColor($new_w,$new_h);
// PUT THE BIG PICTURE ONTO THE THUMBNAIL IMAGE:
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,$old_x,$old_y);
// ADD 2 WHITE RECTANGLES WITH BLACK OUTLINES:
$white = ImageColorAllocate($dst_img, 255, 255, 255);
$black = ImageColorAllocate($dst_img, 100, 100, 100);
imagefilledrectangle($dst_img,292,347,581,541,$black);
imagefilledrectangle($dst_img,293,348,580,540,$white);
imagefilledrectangle($dst_img,292,547,581,741,$black);
imagefilledrectangle($dst_img,293,548,580,740,$white);
// WRITE TEXT TO THE FIRST WHITE BOX:
ImageTTFText($dst_img,20,0,300,375,-$black,"../ARIALNBI.TTF","PHP ROCKS!");
// OUTPUT THE THUMBNAIL (REFERRED TO USING IT'S RESOURCE ID: $dist_img) TO THE PAGE:
imagejpeg($dst_img,$filename,"99");
// GET RID OF RESOURCE IDs FOR THE THUMBNAIL:
imagedestroy($dst_img);
imagedestroy($src_img);
}
//--------------------------------------------------------
createthumb("initial-image.jpg","final-image.jpg",600,750);
?>
<img src=final-image.jpg>
Any help you guys can give would be super super super appreciated! Many thanks!