首页 > 代码库 > PHP之水印
PHP之水印
1 <?php 2 3 //水印制作 4 $create_func_list = array( 5 6 ‘image/jpeg‘ => ‘imagecreatefromjpeg‘, 7 ‘image/png‘ => ‘imagecreatefrompng‘ 8 ); 9 10 $output_func_list =array( 11 12 ‘image/jpeg‘ => ‘image/jpeg‘ 13 14 ); 15 16 //待加水印的图片 17 $dst_file = ‘psb.jpg‘; 18 $stamp_file = ‘stamp.jpg‘; 19 20 $dst_info = getimagesize($dst_file); 21 $dst_mime = $dst_info[‘mime‘]; 22 23 $dst_create_func = $create_func_list[$dst_mime]; 24 $dst_image = $dst_create_func($dst_file); 25 26 $stamp_image = imagecreatefromjpeg($stamp_file); 27 $stamp_w = imagesx($stamp_image); 28 $stamp_h = imagesy($stamp_image); 29 30 //印章位置 31 $dst_x = 200; 32 $dst_y = 80; 33 34 //印章采样位置 35 $stamp_area_x = 0; 36 $stamp_area_y = 0; 37 $stamp_area_w = $stamp_w; 38 $stamp_area_h = $stamp_h; 39 40 $pct = 25; 41 //采样 拷贝 合并 42 imagecopymerge($dst_image, $stamp_image, $dst_x, $dst_y, $stamp_area_x,$stamp_area_y , $stamp_area_w,$stamp_area_h , $pct); 43 44 header("content-type:image/jpeg"); 45 imagejpeg($dst_image); 46 imagedestroy($dst_image); 47 imagedestroy($stamp_image);
PHP之水印
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。