The script below runs without any errors (I’ve enabled all PHP errors just to be sure). But the file that is saved out does not have the watermark on it anywhere. Just the original source image.
Here is a live example for you to view:
[php]
<?php $thumb_dir = "img/"; $perm_name = "wm_news001.jpg"; $filename = $thumb_dir.$perm_name; echo "WATERMARK IMAGE:BEFORE:
$filename
"; $watermark = imagecreatefrompng('img/video-icon.png'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatefromjpeg($filename); $size = getimagesize($filename); $dest_x = $size[0] - $watermark_width; $dest_y = $size[1] - $watermark_height; imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); echo "
AFTER:
$filename"; ?>
[/php]
NOTE: This version uses imagecopy() instead of imagecopymerge() due to it’s PNG-24 support. And yes, I was using PNG-8 when I was using the imagecopymerge() function.
Regardless, it’s still not working. Any ideas?