python PIL 单张图像变换大小—— img.resize()
生活随笔
收集整理的這篇文章主要介紹了
python PIL 单张图像变换大小—— img.resize()
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
from PIL import Image
'''
filein: 輸入圖片
fileout: 輸出圖片
width: 輸出圖片寬度
height:輸出圖片高度
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-qualityout.save(fileout, type)if __name__ == "__main__":filein = r'0.jpg'fileout = r'testout.png'width = 512height = 512type = 'png'ResizeImage(filein, fileout, width, height, type)
這個函數img.resize((width, height),Image.ANTIALIAS)?
第二個參數:?
Image.NEAREST :低質量?
Image.BILINEAR:雙線性?
Image.BICUBIC :三次樣條插值?
Image.ANTIALIAS:高質量
總結
以上是生活随笔為你收集整理的python PIL 单张图像变换大小—— img.resize()的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TensorFlow中loss与val_
- 下一篇: 用matlab绘制一个时钟