Re: Watermarking of images

From: Date: Mon, 11 May 2009 17:39:17 +0000
Subject: Re: Watermarking of images
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-292453@lists.php.net to get a copy of this message
tedd wrote:
At 12:04 AM -0700 5/11/09, Michael A. Peters wrote:
That site is also coded in php so I'm guessing that the watermark is added using a php technology. Can someone enlighten me on how that is done? Also, while not php related, could someone enlighten me of a really good font to use for watermarking images?
Michael: Here's an example with code: http://webbytedd.com/b/watermark/ Cheers, tedd
This is what I'm doing, it seems to work - $im=imagecreatefromjpeg($impath); $text_font="LT_51250.TTF"; imageantialias($im, true); $imw=imagesx($im); $imy=imagesy($im); $string="© " . $somestring; $lbox=imageftbbox($fontsize, 0, $text_font, $string); $color = imagecolorallocate ($im, 255,255,255); $bcolor = imagecolorallocate ($im, 0,0,0); imagefttext($im,$fontsize,0,($xcord - 1),$ycord,$bcolor,$text_font,$string); imagefttext($im,$fontsize,0,($xcord + 1),$ycord,$bcolor,$text_font,$string); imagefttext($im,$fontsize,0,$xcord,($ycord - 1),$bcolor,$text_font,$string); imagefttext($im,$fontsize,0,$xcord,($ycord + 1),$bcolor,$text_font,$string); imagefttext($im,$fontsize,0,$xcord,$ycord,$color,$text_font,$string); header ("Content-type: image/jpeg"); imagejpeg($im); imagedestroy($im); where $impath is the filesystem path to where image is stored, $xcord is x coordinate, $ycord is y coordinate. It does it very nicely. (I changed font to helvetica - it seems to work a little better for this than lucida mono, largely because it isn't monospace).

« previous php.general (#292453) next »