Introduces the process of opening images in python.
Tools/Materials
python3.6
pycharm
Methods/Steps
First, import the PIL module.
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.
# Open the image through the image path image = Image.open(path)
# Print the image information print( image.size, image.format)
Set size image.thumbnail((100, 200))
# Save image.save('3.jpg')
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!