用Python批量更改图片大小
生活随笔
收集整理的這篇文章主要介紹了
用Python批量更改图片大小
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
#提取目錄下所有圖片,更改尺寸后保存到另一目錄
from PIL import Image
import os.path
import glob
def convertjpg(jpgfile,outdir,width=128,height=128):img=Image.open(jpgfile)try:new_img=img.resize((width,height),Image.BILINEAR) new_img.save(os.path.join(outdir,os.path.basename(jpgfile)))except Exception as e:print(e)
for jpgfile in glob.glob("E:\\img\\*.jpg"):convertjpg(jpgfile,"E:\\lianhua")
轉(zhuǎn)載自https://blog.csdn.net/atyzy/article/details/77905463
總結(jié)
以上是生活随笔為你收集整理的用Python批量更改图片大小的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 机器学习中基本线性代数
- 下一篇: python之网络编程1-socket-