Jump to content

Dynamic watermarks with GD can it be done?


cooldude832

Recommended Posts

I'm trying to create a dynamic watermark of my images based on which user owns the image (the site is a image upload/sharing site)

I want to create a semi obaque watermark with the sitename:created by: Username

Any ideas how to do it without doing a text write and without having to create a crazy system of writing my own characters/font face

Yes I believe it can be done.

 

header('Content-Type: image/jpeg');  
$wm = imagecreatefromjpeg('watermark.jpg');
//get dimensions
$h = imagesy($wm);
$w = imagesx($wm);
//load image to be watermarked
$image = imagecreatefromjpeg('image.jpg');
$offset = 10;
$x = imagesx($image) - ($w+$offset);
$y = imagesy($image) - ($h+$offset);
//merges them
imagecopymerge($image, $wm, $x, $y, 0, 0, $w, $h, 100);
imagejpeg($image);
//clear memory
imagedestroy($image);
imagedestroy($wm);

 

Not sure if that works too well, haven't tested it out. But a little fiddling around should make it alright.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.