I am trying to add a watermarks to existing jpeg files in a specific directory.
I am using a function call... the function is this
function watermark($srcfilename, $newname, $watermark, $quality) {
$imageInfo = getimagesize($srcfilename);
$width = $imageInfo[0];
$height = $imageInfo[1];
$logoinfo = getimagesize($watermark);
$logowidth = $logoinfo[0];
$logoheight = $logoinfo[1];
$vertextra =$height - $logoheight;
$vertmargin = round($vertextra);
$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); // output to browser
ImageJPEG($photoImage,"images/watermarked/wm_".$newname, $quality);
ImageDestroy($photoImage);
ImageDestroy($logoImage);
}
When I perform the function, it returns a 500 Server error, and a dumps a file called core in the directory where the .php file is. If I disable the line
$logoImage = ImageCreateFromPNG($watermark);
... the function performs ok, but obviously doesn't create the watermarked jpeg.
Here is my php environment - http://photo.lavertue.com/echo.php - in case it's useful to know to give me a hand. I really don't know this stuff that well, but I know how to edit pretty darn well to make things work for myself. 😉
I would consider myself a deep learner who has used it a bit.
Thanks.