Image processing with Python-resizing a picture

Source: Internet
Author: User
Tags image processing library

Python has an image processing library--pil that can process image files. PIL provides powerful methods such as format conversion, rotation, cropping, resizing, pixel processing, picture merging, and so on.

For a simple example, adjust the size of the picture:

Import imageinfile = ' d:\\original_img.jpg ' outfile = ' d:\\adjust_img.jpg ' im = (infile) (x, y) = im.size #read ima GE sizex_s = #define Standard widthy_s = y * x_s/x #calc height based on standard widthout = Im.resize ((x_s,y_s), Ima Ge. AntiAlias) #resize image with (outfile) print ' original size: ', x,yprint ' adjust size: ', x_s,y_s ' Output:original Size:  358adjust Size:  250 179 "

Image processing with Python-resizing a picture

Related Article

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