In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to use the Pillow library to deal with image files in Python, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Pillow is a very useful library for dealing with images in python. This time I will mainly introduce the basic use of pillow and know what requirements it can solve.
Review Image Mode (mode)
The image coordinate system used by the pillow library
The coordinates of the image start from the upper left corner (0minute 0). The coordinate value represents the angle of the pixel, which is actually located at (0.5). The coordinates in python are usually transmitted in the form of 2 tuples (XMagi Y), and the rectangle is represented as 4 tuples (LilixGravity Tincy, ronomex journal). The X axis is from left to right, and the Y axis is from top to bottom. The order is from the upper left to the lower right. From the upper left corner, such as a 800X600 pixel image rectangle, it is actually locked in the upper left corner and extends to the lower right.
Graphics
Install the pillow method
Pip install pillow
Common methods of pillow
The most common operation is the zoom operation of the image, the code is as follows
From PIL import Image
# Open a jpg image file Note that it is the current path: im = Image.open ('boat_girl.jpg') # to get the image size: W, h = im.sizeprint (' the length and width of the picture is:% sx%s'% (w, h)) # zoomed to 50%:im.thumbnail (w _ sx%s' _ 2, h _ sx%s' _ 2) print ('the length and width of the picture scaled by 50% is:% sx%s'% (w _ print 2) ) # Save the scaled image in jpeg format: im.save ('boat_girl_small.jpg',' jpeg')
The image blur operation is
From PIL import Image, ImageFilter
# Open a jpg image file, note that it is the current path: im = Image.open ('boat_girl.jpg') # apply blur filter: im2 = im.filter (ImageFilter.BLUR) im2.save (' boat_girl_blur.jpg', 'jpeg') above is how to use the Pillow library in Python to deal with image files. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.