03-24-2003, 10:44 PM
is there a method in gd to change an image into a watermark image?
i'm wishing to create an automated process where and image would be automatically converted to 20% opacity against a white matte.
you want to iterate through the image pixel by pixel and then imagecopymerge a sampling over a plain white base
$resource = 'whatever.jpg';
$opacity = 20;
$siz = getimagesize($resource);
$basei = imagecreatefromjpeg($resource);
$newi = imagecreatetruecolor($siz,$siz);
$whit = imagecolorallocate($newi, 255, 255, 255);
for($dy = 0; $dy < $siz; $dy++)
for($dx = 0; $dx < $siz; $dx++)
imagecopymerge($newi, $basei, $dx, $dy, $dx, $dy, 1, 1, $opacity);
imagejpeg($newi, 'folder/save.jpg', 85);
fly typed so will probably parse bad, should point you in the right direction though.
subnote - GD2 functions used.
edit - you wouldn't need to iterate really - lose the for loops and just use
imagecopymerge($newi, $basei, 0, 0, 0, 0, $siz, $siz, $opacity);
11-03-2003, 03:48 AM
This is very cool...
But is there a way to embed the watermark on the top of the image, you know like to have a JPG with a watermark on the top...
And also be able to control the quality and opacity based on the color that we don't want to be visible...
Also I forgot I have GD. 1.6 so imagecreate() is what works not imagecreateTrueColor()