function imageaddlogo($im, $logopath)
 {
     //计算宽和高
     $w = imagesx($im);
     $h = imagesy($im);
     //加载logo
     $ext = substr($logopath, strrpos($logopath, '.'));
     if (empty($ext)) {
         return false;
     }
     switch (strtolower($ext)) {
         case '.jpg':
             $src_im = @imagecreatefromjpeg($logopath);
             break;
         case '.gif':
             $src_im = @imagecreatefromgif($logopath);
             break;
         case '.png':
             $src_im = @imagecreatefrompng($logopath);
             break;
     }
     $src_im = $this->resizeImage($src_im, $w / 4, $h / 4);
     $src_w = imagesx($src_im);
     $src_h = imagesy($src_im);
     //logo边框1 小
     $bor1 = ImageCreate($src_w + 2, $src_h + 2);
     ImageColorAllocate($bor1, 237, 234, 237);
     //背景色
     $bor1_w = imagesx($bor1);
     $bor1_h = imagesy($bor1);
     //logo边框2 中
     $bor2 = ImageCreate($bor1_w + 8, $bor1_h + 8);
     ImageColorAllocate($bor2, 255, 255, 255);
     //背景色
     $bor2_w = imagesx($bor2);
     $bor2_h = imagesy($bor2);
     //logo边框3 大
     $bor3 = ImageCreate($bor2_w + 2, $bor2_h + 2);
     ImageColorAllocate($bor3, 215, 215, 215);
     //背景色
     $bor3_w = imagesx($bor3);
     $bor3_h = imagesy($bor3);
     //圆角处理
     $rounder = new RoundedCorner('', 5);
     //二维码与logo边框3合并
     //        $bor3=$rounder->round_it($bor3);
     //        imagecopymerge($im, $bor3, ($w/2)-($bor3_w/2), ($h/2)-($bor3_h/2), 0, 0, $bor3_w, $bor3_h, 50);
     //        imagedestroy($bor3);
     //二维码与logo边框2合并
     //        $bor2=$rounder->round_it($bor2);
     //        imagecopymerge($im, $bor2, ($w/2)-($bor2_w/2), ($h/2)-($bor2_h/2), 0, 0, $bor2_w, $bor2_h, 60);
     //        imagedestroy($bor2);
     //
     //       //二维码与logo边框1合并
     $bor1 = $rounder->round_it($bor1);
     imagecopymerge($im, $bor1, $w / 2 - $bor1_w / 2, $h / 2 - $bor1_h / 2, 0, 0, $bor1_w, $bor1_h, 40);
     imagedestroy($bor1);
     //二维码与logo合并
     $src_im = $rounder->round_it($src_im);
     imagecopymerge($im, $src_im, $w / 2 - $src_w / 2, $h / 2 - $src_h / 2, 0, 0, $src_w, $src_h, 100);
     imagedestroy($src_im);
     return $im;
 }
Example #2
0
 public static function set_radius($path, $radius, $npath = null)
 {
     if ($npath == null) {
         $npath = $path;
     }
     $rounder = new RoundedCorner($path, $radius);
     $iimg = $rounder->round_it();
     imagepng($iimg, $npath);
 }