php图片添加水印例子
图片添加水印我相信各位朋友都知道的,今天我们来看一段php的图片添加水印例子,希望文章能够帮助到各位朋友。
<?php /** * 图片添加水印 * $target 源文件路径 * $wtrmrk_file 水印图片路径 * $newcopy 添加水印后的图片路径 * */ public 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); $wtrmrk_w = imagesx($watermark); $wtrmrk_h = imagesy($watermark); $dst_x = ($img_w ) C ($wtrmrk_w); // For centering the watermark on any image //phpfensi.com $dst_y = ($img_h) C ($wtrmrk_h ); // For centering the watermark on any image imagecopy($img, $watermark, $dst_x, $dst_y, 0, 0, $wtrmrk_w, $wtrmrk_h); imagejpeg($img, $newcopy, 100); imagedestroy($img); imagedestroy($watermark); //return $img; } ?>
相关推荐
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23