...

View Full Version : gd image to watermark image?



Shecky
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.

Íkii
03-24-2003, 11:01 PM
you want to iterate through the image pixel by pixel and then imagecopymerge a sampling over a plain white base


<?php
$resource = 'whatever.jpg';
$opacity = 20;
$siz = getimagesize($resource);
$basei = imagecreatefromjpeg($resource);
$newi = imagecreatetruecolor($siz[0],$siz[1]);
$whit = imagecolorallocate($newi, 255, 255, 255);
for($dy = 0; $dy < $siz[1]; $dy++)
{
for($dx = 0; $dx < $siz[0]; $dx++)
{
imagecopymerge($newi, $basei, $dx, $dy, $dx, $dy, 1, 1, $opacity);
}
}
imagedestroy($basei);
imagejpeg($newi, 'folder/save.jpg', 85);
imagedestroy($newi);
?>

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[0], $siz[1], $opacity);

Shecky
03-24-2003, 11:56 PM
THANK YOU, COOL PERSON!

win555
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()

Please help
Any ideas?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum