PHPThumb image processing example

Source: Internet
Author: User
PHPThumb image processing example

  1. Function about_phpthumb (){

  2. Require_once './js/phpthumb/ThumbLib. inc. php ';

  3. // Instantiate the class library. the address of the image you want to process can be a network address or a local address.

  4. $ Thumb = PhpThumbFactory: create ('./images/cake.png ');

  5. // Scale down the image to a maximum width of PX or a maximum of px. when only one parameter is input, the maximum width is limited.

  6. $ Thumb-> resize (100,100 );
  7. // $ Thumb-> show ();

  8. // Reduce the image proportional ratio to the original percentage. for example, 50 is the original 50%.

  9. $ Thumb-> resizePercent (50 );
  10. // $ Thumb-> show ();

  11. // Intercept a 175px * 175px Image. Note that this is the intercept. the excess part is directly cropped, not forcibly changed.

  12. $ Thumb-> adaptiveResize (175,175 );
  13. // $ Thumb-> show ();

  14. // Extract a PX * px image from the image center.

  15. $ Thumb-> cropFromCenter (200,100 );
  16. // $ Thumb-> show ();

  17. // The first two parameters are the coordinates X and Y in the upper-right corner of the image to be extracted. The following two parameters are the width and height of the image to be solved.

  18. $ Thumb-> crop (100,100,300,200 );
  19. // $ Thumb-> show ();

  20. // Reverse the image clockwise to 180 degrees

  21. $ Thumb-> rotateImageNDegrees (180 );
  22. // $ Thumb-> show ();

  23. Try {

  24. $ Thumb = PhpThumbFactory: create ('./images/girl.png ');
  25. }
  26. Catch (Exception $ e ){
  27. Throw $ e;
  28. }

  29. $ Thumb-> crop (100,100,300,200 );

  30. // $ Thumb-> show ();

  31. $ Thumb-> cropFromCenter (200,100 );

  32. // $ Thumb-> show ();

  33. $ Thumb-> adaptiveResize (250,250)-> createReflection (40, 80, 80, true, '# a4a4a4'); // reflection (reflection). The color is the border color of the source image.

  34. // $ Thumb-> show ();

  35. $ Thumb-> rotateImage ('cw ');

  36. // $ Thumb-> show ();

  37. $ Thumb-> adaptiveResize (300,300 );

  38. $ Thumb-> save ('. /images/girl2.jpg ', 'jpg'); // save the image. The first parameter is the name of the saved image, and the second parameter is the conversion format of the image.

  39. $ Thumb-> resize (150,200)-> cropFromCenter (100)-> show (); // chain lock function

  40. }

Appendix, phpthumb image processing class library: https://github.com/masterexploder/PHPThumb

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.