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