Home > php教程 > PHP源码 > thinkphp+jcrop打造的强迫症头像制作

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

PHP中文网
Release: 2016-05-25 16:58:08
Original
1705 people have browsed it

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));
Copy after login

                   

                   

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template