>백엔드 개발 >PHP 튜토리얼 >该如何去调用这个类

该如何去调用这个类

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB원래의
2016-06-13 11:36:07920검색

该怎么去调用这个类?

<?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>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.