알파 채널을 사용하여 이미지에 워터마크 추가

예제 #1 알파 채널을 사용하여 이미지에 워터마크 추가

                  
<?php
// Load the stamp and the photo to apply the watermark to
$stamp = imagecreatefrompng('stamp.png');
$im = imagecreatefromjpeg('photo.jpeg');

// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);

// Copy the stamp image onto our photo using the margin offsets and the photo
// width to calculate positioning of the stamp.
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
                  
                

image examples-watermark

이 예는 사진과 저작권이 있는 이미지에 워터마크와 스탬프를 추가하는 일반적인 방법입니다. 텍스트로 스탬프 이미지에 알파 채널이 있으면 앤티앨리어싱됩니다. 이것은 복사하는 동안 보존됩니다.