You are here: What's wrong with this picture? (branding function makes solid bl ack image) « PHP « IT news, forums, messages
What's wrong with this picture? (branding function makes solid bl ack image)

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");

?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация