|
Posted by Jim Moseby on 08/26/05 16:50
What's wrong with this picture? Well, nothing. That is, until you run the
following code on it. Then it becomes a solid black box with the intended
white brand at the bottom left. :-/
What it is supposed to do is place a 4 pixel wide black border around the
image, then brand an image with a copyright symbol (chr(169)) and some text.
It actually brands it twice, first in black, then in white, offset two
pixels vertically and horizontally. I thought it was the border part that
was crewing up, so I remarked that line out, but it still munges the
picture. Where have I gone wrong?
JM
<?
function brand_image($big_pic){// Draw border and brand big_pic
$borderwidth=4;
$fontpath="/www/PAPYRUS.TTF"; //path to font file
$brandtext=chr(169)."2005, example.com"; //text of image brand
$ims=getimagesize($big_pic);
$img = ImageCreateTrueColor($ims[0],$ims[1]);
$black = imagecolorallocate ($img, 0, 0, 0);
$white = imagecolorallocate ($img, 255, 255, 255);
imagecopy($img,$org_img, 0, 0, 0, 0, $ims[0], $ims[1]);
//for($x=0;$x<$borderwidth;$x++){imagerectangle($img,$x,$x,$ims[0]-(1+$x),$i
ms[1]-(1+$x), $black);}
imagettftext($img,20, 0, $ims[0]-260, $ims[1]-20, $black, $fontpath,
$brandtext);
imagettftext($img,20, 0, $ims[0]-262, $ims[1]-22, $white, $fontpath,
$brandtext);
imagejpeg($img,$big_pic,90);
imagedestroy($img);
} //function brand_image
brand_image("/www/test.jpg");
?>
[Back to original message]
|