Home  >  Article  >  Backend Development  >  该如何去调用这个类

该如何去调用这个类

WBOY
WBOYOriginal
2016-06-13 12:37:04872browse

该怎么去调用这个类?

<?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>
Statement:
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