PHP Implementation of image scaling (master fly)

Source: Internet
Author: User
PHP implements simple image scaling.
  1. /**
  2. * Images class is a picture processing class
  3. * @author Pan
  4. * @package Application.controllers
  5. * @since 1.0
  6. */
  7. Class Images
  8. {
  9. /**
  10. * Zoom Picture
  11. * @param $source Original picture
  12. * @param $newfile New pictures
  13. * @param $pre Scale
  14. */
  15. Public Function Thumn ($source, $pre, $newfile)
  16. {
  17. Get picture size
  18. List ($s _w, $s _h) =getimagesize ($source);
  19. Create a new picture size
  20. $new _w= $s _w* $pre;
  21. $new _h= $s _h* $pre;
  22. Create a new image
  23. $new _f=imagecreatetruecolor ($new _w, $new _h);
  24. Create an image with a resource picture
  25. $sour _f=imagecreatefromjpeg ($source);
  26. Copy a resource picture to a new image
  27. Imagecopyresampled ($new _f, $sour _f, 0, 0, 0, 0, $new _w, $new _h, $s _w, $s _h);
  28. Output image to Browser
  29. Imagejpeg ($new _f, $newfile);
  30. Imagedestroy ($new _f);
  31. Imagedestroy ($sour _f);
  32. }
  33. }
  34. ?>
Copy Code
  • 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.