1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
function watermark_image($target, $wtrmrk_file, $newcopy) { $watermark = imagecreatefrompng($wtrmrk_file); imagealphablending($watermark, false); imagesavealpha($watermark, true); $img = imagecreatefromjpeg($target); $img_w = imagesx($img); $img_h = imagesy($img); $marge_right = 5; $marge_bottom = 5; $wtrmrk_w = imagesx($watermark); $wtrmrk_h = imagesy($watermark); imagecopy($img, $watermark, imagesx($img) - $wtrmrk_w - $marge_right, imagesy($img) - $wtrmrk_h - $marge_bottom, 0, 0, imagesx($watermark), imagesy($watermark)); imagejpeg($img, $newcopy, 90); imagedestroy($img); imagedestroy($watermark); } watermark_image('img.jpg','watermark.png', 'new_image_name.jpg'); |
Leave a reply