PHP image Processing class: Thumbnail, crop, fillet, tilt (1/3) _php Tutorial

Source: Internet
Author: User
This article provides a free PHP image processing class: Thumbnail, clipping, fillet, tilt code, he can cut out different styles of pictures oh, haha, more than the other online cut diagram is much better oh.

PHP Tutorial Picture Processing class: Thumbnail, crop, fillet, tilt

Class Resizeimage
{
Type of picture
var $type;
Actual width
var $width;
Actual height
var $height;
The width after the change
var $resize _width;
The height after the change
var $resize _height;
Whether or not to cut the map
var $cut;
Source image
var $srcimg;
Target image Address
var $dstimg;
Fillet 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 picture
$this->type = substr (STRRCHR ($this->srcimg, "."), 1);
Initializing an image
$this->initi_img ();
Destination image Address
$this-dst_img ();
//--
$this->width = imagesx ($this->im);
$this->height = Imagesy ($this->im);
Creating images
$this->newimg ();
Imagedestroy ($this->im);
}
function newimg ()
{
The proportions of the altered image
$resize _ratio = ($this->resize_width)/($this->resize_height);
Ratio of actual images
$ratio = ($this->width)/($this->height);
if (($this->cut) = = "1")
Crop chart
{
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->rounded_corner ($newimg, $this->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));
$tmp = $this->rounded_corner ($newimg);
Imagepng ($tmp, $this->dstimg);
}
}
Else

1 2 3

http://www.bkjia.com/PHPjc/633021.html www.bkjia.com true http://www.bkjia.com/PHPjc/633021.html techarticle This article provides a free PHP image processing class: Thumbnail, clipping, fillet, tilt code, he can cut out different styles of pictures oh, haha, more than the other online cutting diagram is much better oh ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.