Php scaling Image instance code

Source: Internet
Author: User
Php scaling Image instance code

  1. Include ('simpleimage. php ');
  2. $ Image = new SimpleImage ();
  3. $ Image-> load('picture.jpg ');
  4. $ Image-> resize( 250,400 );
  5. $ Image-> save('picture2.jpg ');?>

2. set the width and proportional scaling

  1. Include ('simpleimage. php ');
  2. $ Image = new SimpleImage ();
  3. $ Image-> load('picture.jpg ');
  4. $ Image-> resizeToWidth (250 );
  5. $ Image-> save('picture2.jpg ');?>

3. set the height and proportional scaling

  1. Include ('simpleimage. php ');
  2. $ Image = new SimpleImage ();
  3. $ Image-> load('picture.jpg ');
  4. $ Image-> resizeToHeight (500 );
  5. $ Image-> save('picture2.jpg ');
  6. $ Image-> resizeToHeight (200 );
  7. $ Image-> save('picture3.jpg ');?>

4. scale to 50% in proportion

  1. Include ('simpleimage. php ');
  2. $ Image = new SimpleImage ();
  3. $ Image-> load('picture.jpg ');
  4. $ Image-> scale (50 );
  5. $ Image-> save('picture2.jpg ');?>

5. zoom in and out to the screen

  1. Header ('content-Type: image/jpeg ');
  2. Include ('simpleimage. php ');
  3. $ Image = new SimpleImage ();
  4. $ Image-> load('picture.jpg ');
  5. $ Image-> resizeToWidth (150 );
  6. $ Image-> output ();?>

Note: SimpleImage. php can be obtained from the download link provided at the beginning of this article.

>>> Articles you may be interested in: examples of php and other proportional scaling images refer to SimpleImage, a tool such as php, to learn the code example of php batch scaling images

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.