So i've added a watermark script to my website that will add a watermark to any image unless it's a thumbnail (150x150) as it will look stupid.
As you can see here though (Link) there are 2 images for bacata and boogie bug and the star rating down the bottom. These end up being watermarked and look terrible.
The Code:
Thanks,
Andy
As you can see here though (Link) there are 2 images for bacata and boogie bug and the star rating down the bottom. These end up being watermarked and look terrible.
The Code:
As you can see from this bit of code:<?
$src = $_GET['src'];
header('Content-type: image/jpeg');
//this will prevent the watermark from showing up in the thumbnail images
if (eregi("150x150", $src)) {
$watermark = imagecreatefrompng('empty.png');
} else {
$watermark = imagecreatefrompng('watermark.png');
}
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
if(eregi('.gif',$src)) {
$image = imagecreatefromgif($src);
}
elseif(eregi('.jpeg',$src)||eregi('.jpg',$src)) {
$image = imagecreatefromjpeg($src);
}
elseif(eregi('.png',$src)) {
$image = imagecreatefrompng($src);
}
else {
exit("Your image is not a gif, jpeg or png image. Sorry.");
}
$size = getimagesize($src);
$dest_x = $size[0] - $watermark_width - 0;
$dest_y = $size[1] - $watermark_height - 0;
imagecolortransparent($watermark,imagecolorat($watermark,0,0));
imagecopyresampled($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $watermark_width, $watermark_height);
imagejpeg($image, "", 95);
imagedestroy($image);
imagedestroy($watermark);
?>
It prevents it from being in 150x150 images. Instead of excluding the size of the other images, all my images that i want watermarked are 960x720, so how would i make the rule so that the only images that get watermarked are 960x720?//this will prevent the watermark from showing up in the thumbnail images
if (eregi("150x150", $src)) {
Thanks,
Andy
Last edited: