Home  >  Article  >  Backend Development  >  How to open pictures with zero basic knowledge of python

How to open pictures with zero basic knowledge of python

步履不停
步履不停Original
2019-07-02 15:13:224578browse

How to open pictures with zero basic knowledge of python

Introduces the process of opening images in python.

Tools/Materials

python3.6

pycharm

Methods/Steps

First, import the PIL module.

How to open pictures with zero basic knowledge of python

Then, save a path variable of the image. In this example, the image is in the directory where the py file is located, so when using a relative path, just use the image name.

How to open pictures with zero basic knowledge of python

# Open the image through the image path image = Image.open(path)

How to open pictures with zero basic knowledge of python

# Print the image information print( image.size, image.format)

How to open pictures with zero basic knowledge of python

Set size image.thumbnail((100, 200))

How to open pictures with zero basic knowledge of python

# Save image.save('3.jpg')

How to open pictures with zero basic knowledge of python

END

Notes

Also You can download the third-party module pillow to process images conveniently and quickly

Recommended related tutorials:Python video tutorial

The above is the detailed content of How to open pictures with zero basic knowledge of python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is std in pythonNext article:What is std in python