I create a watermark function, that adds a simple small watermark on the bottom right corner of images. Everything work fine...except one problem. This function quadruples the size of the image. (Started with a 92k image, it is now 242k) What can I do to this function to make it better?
function watermark($srcfilename, $newname, $watermark,$wm_left, $wm_top, $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 = $wm_left;
$vertmargin = $wm_top;
$photoImage = ImageCreateFromJPEG($srcfilename);
ImageAlphaBlending($photoImage, true);
$logoImage = ImageCreateFromPNG($watermark);
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
ImageCopy($photoImage, $logoImage, $horizmargin, $vertmargin, 0, 0, $logoW, $logoH);
ImageJPEG($photoImage,$newname, $quality);
ImageDestroy($photoImage);
ImageDestroy($logoImage);
}
Thanks!
Matthew