//$h = $arr[1];// create image and define colors$image = imagecreatetruecolor($width,$heights); //创建一个彩色的底图$bg = imagecolorallocate($image, 255, 255, 255);imagefill($image,0,0,$bg);$imgsrc = loadimg($imgsrc,$arr['mime']);imagecopy($image,$imgsrc,$img_x,$img_y,0,0,$arr[0],$arr[1]);imagejpeg($image,$imgdst,90);//imagedestroy($image);}// 加载背景图片function loadimg($imgname,$mime){ if($mime == image/gif){ $im = @imagecreatefromgif($imgname); /* attempt to open */ } elseif ($mime == image/png){ $im = @imagecreatefrompng($imgname); /* attempt to open */ } else{ $im = @imagecreatefromjpeg($imgname); /* attempt to open */ } if(!$im) { /* see if it failed */ $im = imagecreatetruecolor(150, 30); /* create a blank image */ $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); /* output an errmsg */ imagestring($im, 1, 5, 5, error loading $imgname, $tc); } return $im;}
复制代码