欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

thinkphp+jcrop打造的强迫症头像制作

程序员文章站 2022-04-27 09:10:11
...

1. [图片] qb.png

thinkphp+jcrop打造的强迫症头像制作

2. [PHP]代码

//重点代码
//拷贝头像到新画布
$newhead = imageCreatetruecolor(180,180);//新建白板,头像
imagesavealpha($newhead, true);
$color = imagecolorallocatealpha($newhead, 255, 255, 255,127);
imagecolortransparent($newhead,$color);
imagefill($newhead, 0, 0, $color);	
imagecopyresampled($newhead,$image,20,20,0,0,imagesx($image),imagesy($image),imagesx($image),imagesy($image));

//新建画布拷贝数字背景				
$num_bg="./Public/Images/icon-head2.png";
$num_bg_src = imagecreatefrompng($num_bg);

$num_bg_new = imageCreatetruecolor(imagesx($num_bg_src),imagesy($num_bg_src));
imagesavealpha($num_bg_new, true);
//为真彩色画布创建白色背景,再设置为透明
$color = imagecolorallocatealpha($num_bg_new, 255, 255, 255,127);
imagecolortransparent($num_bg_new,$color);
imagefill($num_bg_new, 0, 0, $color);
imagecopyresampled($num_bg_new,$num_bg_src,0,0,0,0,imagesx($num_bg_new),imagesy($num_bg_new),imagesx($num_bg_new),imagesy($num_bg_new));
相关标签: php