Jump to content

Trying to watermark an image, but it isn't working.


brooksh

Recommended Posts

Here is my script. Can anyone tell me what I'm doing wrong?

 

		
                $dw = 640;
	$prop = ($oldimagesize[0]/$dw);
	$dh = ($oldimagesize[1]/$prop);
	$sw = $oldimagesize[0];
	$sh = $oldimagesize[1];

	$largeimagename = 'large_' . $newimagename;
	$largeimagefull = $uploadDir . $largeimagename;

	$largeimage = imagecreatetruecolor($dw, $dh);
	imagecopyresampled($largeimage, $oldimage, 0, 0, 0, 0, $dw, $dh, $sw, $sh);

$watermark = imagecreatefrompng('/home/photos/public_html/images/watermark.png');
$watermark_width = imagesx($watermark);  
$watermark_height = imagesy($watermark);
$largeimage = imagecreatefromjpeg($largeimage);
$size = getimagesize($largeimage);  
$dest_x = $size[0] - $watermark_width - 5;  
$dest_y = $size[1] - $watermark_height - 5;
imagecopymerge($largeimage, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
imagedestroy($watermark);

	call_user_func("image" . $imageTypes[$oldimagesize[2]], $largeimage, $largeimagefull);

ooh blimey... good luck. watermarking is a nightmare. I managed to do it on http://www.nextdaygraphics.com have a look and let me know if that's the kind of thing that you want and I'll see if i can dig out the code.

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.