PHP image processing categories: thumbnail, crop, rounded corners, tilt (1/3)_PHP tutorial

WBOY
Release: 2016-07-13 10:45:25
Original
1237 people have browsed it

This article provides a PHP image processing class for free: thumbnail, crop, rounded corners, and tilt codes. It can cut pictures of different styles, haha, it is much better than other online picture cutting methods.

PHP tutorial image processing categories: thumbnail, crop, rounded corners, tilt

class resizeimage
{
//Image type
var $type;
//Actual width
var $width;
//Actual height
var $height;
//Changed width
var $resize_width;
//Height after change
var $resize_height;
//Whether to crop the image
var $cut;
//Source image
var $srcimg;
//Target imageAddress
var $dstimg;
//Round corner source
var $corner;
var $im;

function resizeimage($img, $corner, $wid, $hei,$c, $corner_radius, $angle)
{
$this->srcimg = $img;
$this->corner = $corner;
$this->resize_width = $wid;
$this->resize_height = $hei;
$this->cut = $c;
$this->corner_radius = $corner_radius;
$this->angle = $angle;
//Type of image
$this->type = substr(strrchr($this->srcimg,"."),1);
//Initialize image
$this->initi_img();
//Target image address
$this -> dst_img();
​ ​ //--
$this->width = imagesx($this->im);
$this->height = imagesy($this->im);
//Generate image
$this->newimg();
Imagedestroy ($this->im);
}
function newimg()
{
//The proportion of the changed image
$resize_ratio = ($this->resize_width)/($this->resize_height);
​​​ //Actual image ratio
$ratio = ($this->width)/($this->height);
If(($this->cut)=="1")
//Crop image
        {
               if($ratio>=$resize_ratio)
​​​​//High priority
              {
$newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);
imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this ->height);
$ TMP = $ This-& GT; Rounded_corner ($ newimg, $ this-& gt; resize_width);
Imagepng ($tmp,$this->dstimg);
           }
                    if($ratio<$resize_ratio)
                                                                                                                                                               // width first
              {
                   $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height);
imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width) /$resize_ratio));
                                                                                                                                                                                                                                                      through Imagepng ($tmp,$this->dstimg);
           }
}
      else
       

1 2 3

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633021.htmlTechArticleThis article provides a free PHP image processing class: thumbnail, cropping, rounded corners, tilt code, he can Cut out pictures in different styles, haha, it’s much better than other online cutouts...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template