What's wrong with this picture? (branding function makes solid bl ack image)

From: Date: Fri, 26 Aug 2005 13:50:17 +0000
Subject: What's wrong with this picture? (branding function makes solid bl ack image)
Groups: php.general 
Request: Send a blank email to php-general+get-221443@lists.php.net to get a copy of this message
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"); ?>

« previous php.general (#221443) next »