<?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);
?>
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,