i found a script a while back that did pretty much what i've always wanted to do... watermark an image...
now, since i'm dumb, i can't figure out how to get the image to appear at the BOTTOM RIGHT of an image according to its height and width or whatever.
example:
http://robsgaming.com/testing/watermark/images/watermarked/wm_stadium_web.jpg
you will notice robsgaming log is at top left, i want it to be on bottom right:
here is the code:
<?php
$watermark = "proof150.png";
$quality = "75";
$imagedir = "images";
$workingdir = opendir ($imagedir);
while ($entry = readdir($workingdir)) {
if(eregi(".+\.jpe?g$", $entry )) {
$i=1;
watermark($imagedir."/".$entry, $entry, $watermark, $quality);
$i++;
}
}
//$filename should be a JPG and $watermark a PNG-24 with alpha transparency. $quality is 1-100 JPG quality on output.
function watermark($srcfilename, $newname, $watermark, $quality) {
$imageInfo = getimagesize($srcfilename);
$width = $imageInfo[0];
$height = $imageInfo[1];
$logoinfo = getimagesize($watermark);
$logowidth = $logoinfo[0];
$logoheight = $logoinfo[1];
$horizextra =$width - $logowidth;
$vertextra =$height - $logoheight;
$horizmargin = round($horizextra / 2);
$vertmargin = round($vertextra / 2);
$photoImage = ImageCreateFromJPEG($srcfilename);
ImageAlphaBlending($photoImage, true);
$logoImage = ImageCreateFromPNG($watermark);
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
ImageCopy($photoImage, $logoImage, 1, 1, 0, 0, $logoW, $logoH);
//ImageJPEG($photoImage); // output to browser
ImageJPEG($photoImage,"images/watermarked/wm_".$newname, $quality);
ImageDestroy($photoImage);
ImageDestroy($logoImage);
}
?>
any help is greatly appreciated, i'm not good at math or thinking really, and cant figure out any forumla or whatever of how to figure out the bottom coordinates. again, i want rg logo to appear on bottom right... right now i have image copy placing it at 1,1 --- those should be a variable im guessing.