asked on
$photo_name = "AC001.jpg";
$gallery_name = "Fall Colors";
function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile) {
list($width, $height) = getimagesize($SourceFile);
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($SourceFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height);
$black = imagecolorallocatealpha($image_p, 255, 255, 255, 99);
$font = '../admin/arial.ttf';
$font_size = 400;
$overlay_height = "391";
$overlay_width = "395";
$o_width = $overlay_width/2;
$i_width = $width/2;
$x_pos = $i_width - $o_width;
$o_height = $overlay_height/2;
$i_height = $height/2;
$y_pos = $i_height + $o_height;
imagettftext($image_p, $font_size, 0, $x_pos, $y_pos, $black, $font, $WaterMarkText);
if ($DestinationFile<>'') {
imagejpeg ($image_p, $DestinationFile, 100);
} else {
header('Content-Type: image/jpeg');
imagejpeg($image_p, null, 100);
};
imagedestroy($image);
imagedestroy($image_p);
};
$SourceFile = "../galleries/$gallery_name/$photo_name";
$DestinationFile = "";
$WaterMarkText = '©';
watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile);