Watermark your images using PHP
Aprilie 1st, 2007
Do you have an image that you want to keep a copyright on? Putting you logo or a URL of your website on each and every image is a quite a long and tedious process so here is a solution in PHP that will help you make things easier and neater.
Using this script one can specify two images: the image to be watermarked and the watermark itself. If you have several images do not waste time putting your watermark on each and every image. Just use this script and all your images are watermarked
$_image = “snippetcollection.jpg”‘; $watermark = ‘watermark.png’;
$watermark = imagecreatefrompng($watermark); //gets the watermark
//gets the dimensions of the watermark
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
//gets the image to put the watermark on and related information about it
$image = imagecreatefromjpeg($_image);
$size = getimagesize($_image);
$dest_x = $size[0] - $watermark_width - 5;
$dest_y = $size[1] - $watermark_height - 5;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
?>
If you would like more interesting snippets and examples in PHP visit http://www.snippetcollection.com. There you can find a large number of snippets in various languages such as PHP, Javascript and other languages.
Note this script is inspired by a sitepoint article.

Foundations of Ajax

















Prima pagina



Comentarii
Trebuie sa fi autentificat pentru a adauga un comentariu.