PHP Implementation Picture scaling function class _php instance

Source: Internet
Author: User
Copy the Code code as follows:
/**
* Images class is a picture processing class
* @package Application.controllers
* @since 1.0
*/
Class Images
{


/**
* Zoom Picture
* @param $source Original picture
* @param $newfile New pictures
* @param $pre Scale
*/
Public Function Thumn ($source, $pre, $newfile)
{
Get picture size
List ($s _w, $s _h) =getimagesize ($source);
Create a new picture size
$new _w= $s _w* $pre;
$new _h= $s _h* $pre;

Create a new image
$new _f=imagecreatetruecolor ($new _w, $new _h);
Create an image with a resource picture
$sour _f=imagecreatefromjpeg ($source);
Copy a resource picture to a new image
Imagecopyresampled ($new _f, $sour _f, 0, 0, 0, 0, $new _w, $new _h, $s _w, $s _h);
Output image to Browser
Imagejpeg ($new _f, $newfile);

Imagedestroy ($new _f);
Imagedestroy ($sour _f);
}
}
?>

  • 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.