Php implementation of image scaling function class _ PHP Tutorial

Source: Internet
Author: User
Php supports image scaling. Copy the code as follows :? Php *** Images class is an image processing class * @ packageapplication. controllers * @ since1.0 * classImages {*** Zoom image ** @ param $ source original image The code is as follows:


/**
* The Images class is an image processing class.
* @ Package application. controllers
* @ Since 1.0
*/
Class Images
{


/**
* Scale an image
* @ Param $ source original image
* @ Param $ newfile New Image
* @ Param $ pre zoom ratio
*/
Public function thumn ($ source, $ pre, $ newfile)
{
// Obtain the image size
List ($ s_w, $ s_h) = getimagesize ($ source );
// Generate a new image 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 image
$ Sour_f = imagecreatefromjpeg ($ source );
// Copy the resource image to the new image
Imagecopyresampled ($ new_f, $ sour_f, 0, 0, 0, 0, $ new_w, $ new_h, $ s_w, $ s_h );
// Output the image to the browser
Imagejpeg ($ new_f, $ newfile );

Imagedestroy ($ new_f );
Imagedestroy ($ sour_f );
}
}
?>

The http://www.bkjia.com/PHPjc/621680.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/621680.htmlTechArticle code is as follows :? Php/*** the Images class is an image processing class * @ package application. controllers * @ since 1.0 */class Images {/*** Zoom image * @ param $ source original image...

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.