Forum Moderators: coopster
However, I want these images to be watermarked with a little png file that I have as my watermark and stored in a directory.
I have come up with this script, but it throws out various errors. Please could the experienced review my code as advise where I have gone wrong.
Code:
foreach($img_name as $img) {
//echo "<p><img src='$img' /><br /></p>" ; This line displays the images perfectly. However, I want the code below to work for the watermark.
$img = "<img src='$img' />";
$watermark = imagecreatefrompng('D:/web/mysite/photos/Canadaso-Comblo-2008/watermark.png');
$watermark_width = imagesx($watermark); // Watermark's width
$watermark_height = imagesy($watermark); // Watermark's height
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg($img);
$size = getimagesize($img);
$dest_x = $size[0] - $watermark_width - 5;
$dest_y = $size[1] - $watermark_height - 5;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0,0, $watermark_width, $watermark_height, 100);
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
//The below curly braces are continuation of pervious codes.
}
}
}
}
closedir($dir_list);