以下是引用片段: 以下为引用的内容: <?php //$backfile: 背景图 //$copyfile: 待拷贝的图 //$resultfile: 生成文件保存地址 //$copytox: 拷贝到背景图上的x坐标 //$copytoy: 拷贝到背景图上的y坐标 //$copytowidth: 把待拷贝的图变为多宽 //$copytoheight: 把待拷贝的图变为多高 function imgmerge($backfile,$copyfile,$resultfile,$copytox,$copytoy,$copytowidth,$copytoheight) { //如果文件名后缀不是"png"则返回"" if (getfileupperext($backfile) != "png") return ""; //如果文件名后缀不是"png"则返回"" if (getfileupperext($copyfile) != "png") return ""; $backimg = imagecreatefrompng($backfile); //如果值没有设置,则返回"" if (!isset($backimg )) { return ""; } $backimgx = imagesx($backimg); $backimgy = imagesx($backimg); $copyimg = imagecreatefrompng($copyfile); //如果值没有设置,则返回"" if (!isset($copyimg )) { return ""; } $copyresizeimg = imageresize($copyimg, $copytowidth, $copytoheight); $bcopy = imagecopy($backimg,$copyresizeimg,$copytox,$copytoy,0,0,$copytowidth,$copytoheight); if (!$bcopy ) { return ""; } imagealphablending($backimg, true); imagesavealpha($backimg, true); if (!imagepng($backimg,$resultfile)) return ""; return $resultfile; } //获得传入文件的文件名 function getfileupperext($fullfile) { if (!file_exists($fullfile)) return ""; $pathinfo = pathinfo($fullfile ); return strtoupper($pathinfo[’extension’]); } function imageresize($rimage, $iwidth, $iheight) { $icanvas = imagecreate($iwidth, $iheight); $iwidthx = imagesx($rimage); $iheighty = imagesy($rimage); imagecopyresampled($icanvas, $rimage, 0, 0, 0, 0, $iwidth, $iheight, $iwidthx, $iheighty); return $icanvas; } imgmerge("backimg.png","copyimg.png","imgmerge.png",3,3,30,30); ?> |
新闻热点
疑难解答