新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
pythonPillow圖像處理方法匯總-創(chuàng)新互聯(lián)
這篇文章主要介紹了python Pillow圖像處理方法匯總,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
Pillow中文文檔:https://pillow-cn.readthedocs.io/zh_CN/latest/handbook/tutorial.html
安裝:pip install pillow
操作圖像:
#!/usr/bin/env python3 # _*_ coding utf-8 _*_ __author__ = 'nxz' from PIL import Image, ImageFilter from time import sleep # 打開一個jpg圖像文件 im = Image.open('test.jpg') w, h = im.size # print('圖片的寬:%s,和高:%s' % (w, h)) # 圖片縮放 im.thumbnail((w // 2, h // 2)) w, h = im.size print(w, h) # 縮放之后的圖片重新保存 im.save('thumbnail.jpg', 'jpeg') # 其他功能:切片、旋轉(zhuǎn)、濾鏡、輸出文字、調(diào)色板 # 模糊效果 im2 = im.filter(ImageFilter.BLUR) im2.save('blur.jpg','jpeg')
新聞名稱:pythonPillow圖像處理方法匯總-創(chuàng)新互聯(lián)
當(dāng)前地址:http://biofuelwatch.net/article/dpgpec.html