Python implements the method of changing the image size (based on the Pillow package)

Source: Internet
Author: User
This article mainly introduces how to change the image size using Python, and analyzes how to change the image attributes using the Pillow package in the form of examples, for more information about how to change the image size in Python, see the following example. We will share this with you for your reference. The details are as follows:

1. Pillow is recommended for the PIL package.

2. source code:

# Encoding = UTF-8 # author: walker # date: # function: change the image size import osimport OS. pathfrom PIL import Image ''' filein: input Image fileout: output Image width height: output Image height type: output Image type (png, gif, jpeg ...) '''def ResizeImage (filein, fileout, width, height, type): img = Image. open (filein) out = img. resize (width, height), Image. ANTIALIAS) # resize image with high-quality out. save (fileout, type) if _ name _ = "_ main __": filein = r 'image \ test.png 'fileout = r'image \ testout.png' width = 60 height = 85 type = 'PNG 'ResizeImage (filein, fileout, width, height, type)

I hope this article will help you with Python programming.

For more information about how to change the image size in Python (based on the Pillow package), see PHP!

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.