<?php
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 = imagecolorallocate($image_p, 0, 0, 0);
$font = 'gulim.ttc';
$font_size = 10;
imagettftext($image_p, $font_size, 0, 10, 20, $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 = './source.jpg';
$destinationFile = './watermark.jpg';
$waterMarkText = 'copyright';
waterMarkImage($sourceFile, $waterMarkText, $destinationFile);
?>