首页 > 后端开发 > php教程 > 该如何去调用这个类

该如何去调用这个类

WBOY
发布: 2016-06-13 12:37:04
原创
916 人浏览过

该怎么去调用这个类?

<?php <br />
/*<br>
图片处理类:缩略,裁剪,圆角,倾斜<br>
*/<br>
class resizeimage<br>
{<br>
   //图片类型<br>
   var $type;<br>
   //实际宽度<br>
   var $width;<br>
   //实际高度<br>
   var $height;<br>
   //改变后的宽度<br>
   var $resize_width;<br>
   //改变后的高度<br>
   var $resize_height;<br>
   //是否裁图<br>
   var $cut;<br>
   //源图象<br>
   var $srcimg;<br>
   //目标图象地址<br>
   var $dstimg;<br>
   //圆角源<br>
   var $corner;<br>
   var $im;<br>
function resizeimage($img, $corner, $wid, $hei,$c, $corner_radius, $angle)<br>
   {<br>
       $this->srcimg = $img;<br>
    $this->corner = $corner;<br>
       $this->resize_width = $wid;<br>
       $this->resize_height = $hei;<br>
       $this->cut = $c;<br>
    $this->corner_radius = $corner_radius;<br>
    $this->angle = $angle;<br>
       //图片的类型<br>
       $this->type = substr(strrchr($this->srcimg,"."),1);<br>
       //初始化图象<br>
       $this->initi_img();<br>
       //目标图象地址<br>
       $this -> dst_img();<br>
       //--<br>
       $this->width = imagesx($this->im);<br>
       $this->height = imagesy($this->im);<br>
       //生成图象<br>
       $this->newimg();<br>
       ImageDestroy ($this->im);<br>
   }<br>
   function newimg()<br>
   {<br>
       //改变后的图象的比例<br>
       $resize_ratio = ($this->resize_width)/($this->resize_height);<br>
       //实际图象的比例<br>
       $ratio = ($this->width)/($this->height);<br>
       if(($this->cut)=="1")<br>
       //裁图<br>
       {<br>
           if($ratio>=$resize_ratio)<br>
           //高度优先<br>
           {<br>
               $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);<br>
               imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height);<br>
      $tmp = $this->rounded_corner($newimg,$this->resize_width);<br>
               imagepng ($tmp,$this->dstimg);<br>
           }<br>
           if($ratio
           //宽度优先<br>
           {<br>
               $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);<br>
               imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio));<br>
      $tmp = $this->rounded_corner($newimg);<br>
               imagepng ($tmp,$this->dstimg);<br>
           }<br>
       }<br>
       else<br>
       //不裁图<br>
       {<br>
           if($ratio>=$resize_ratio)<br>
           {<br>
               $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio);<br>
               imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height);<br>
               ImageJpeg ($newimg,$this->dstimg);<br>
           } <div class="clear">
                 
              
              
        
            </div>
登录后复制
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板