PNG Watermarking Not Quite Working
Posted: Sat Jul 12, 2008 10:48 pm
I'm trying to get a script to automatically watermark images uploaded through a form with a png on the server. The problem I'm running into is that when the script copies the watermark onto the image, anywhere that the watermark doesn't cover is replaced with solid black:
Watermarked:
http://fridasaltiel.com/admin/watermark ... sample.jpg
Not watermarked:
http://fridasaltiel.com/admin/sample.jpg
I think it has something to do with the imagecreatetruecolor()... Any help would be greatly appreciated!
Watermarked:
http://fridasaltiel.com/admin/watermark ... sample.jpg
Not watermarked:
http://fridasaltiel.com/admin/sample.jpg
I think it has something to do with the imagecreatetruecolor()... Any help would be greatly appreciated!
Code: Select all
<? header('content-type: image/jpeg');
$watermark = imagecreatefrompng('watermark.png');
$size = getimagesize($_GET['src']);
$watermark_width = $size[0];//imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg($_GET['src']);
$dest_x = 0;
$dest_y = 0;
imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $size[0], $size[1]);
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
?>