php利用gd实现图片的边框
2021-07-14 20:04
标签:create span gif 图片合并 img display efi from 实现 php利用gd实现图片的边框 标签:create span gif 图片合并 img display efi from 实现 原文地址:http://www.cnblogs.com/yanshou/p/7074673.html 1 php
2
3 //实现两张图片合并 并内图片有一定的边框
4
5 $file = ‘image/qr_1047.png‘;
6 $logo = ‘image/logo_1047.jpg‘;
7 $code = ‘image/ewr.png‘;
8
9 $file_info = getimagesize( $file );
10 $fileTmp = imagecreatefrompng( $file );
11
12 thmbPic( $logo,$file_info[0]*0.26 );
13 thmbPic( $logo,$file_info[0]*0.26+6,3 );
14
15 $logo_tmp = imagecreatefromjpeg( $logo );
16 $info_logo = getimagesize( $logo );
17 $y =$file_info[0] *0.36;
18 imagecopymerge($fileTmp, $logo_tmp, $y, $y, 0, 0, $info_logo[0], $info_logo[1],100);
19 imagepng($fileTmp,$code);
20
21 function thmbPic($img,$x=0,$y=0){
22 //获取图片信息
23 $info_logo = getimagesize( $img );
24 //新建临时图片
25 $img_tmp = imagecreatefromjpeg( $img );
26 //新建真彩色图片
27 $img_thm = imagecreatetruecolor($x,$x);
28 $color = imagecolorallocate($img_thm,255,255,255);
29 imagecolortransparent($img_thm,$color);
30 imagefill($img_thm,0,0,$color);
31 //压缩图片
32 if( $y==0 ){
33 imagecopyresampled($img_thm, $img_tmp, $y, $y, 0, 0, $x, $x, $info_logo[0], $info_logo[0]);
34 }else{
35 imagecopy($img_thm, $img_tmp, $y, $y, 0, 0, $info_logo[0], $info_logo[0]);
36 }
37 //保存图片
38 imagejpeg($img_thm,$img);
39 //销毁图片
40 imagedestroy( $img_tmp );
41 imagedestroy( $img_thm );
42 }
上一篇:MVC项目实践(八)——总结
下一篇:Html颜色