Re: Watermarking of images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2009-05-11 at 10:39 -0700, Michael A. Peters wrote:
> 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).

Note that the 1 pixel offset is optional. You could use 2 or more and
get a thicker black border. It might even be nicer looking if you did
all eight directions.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux