欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python3 webp轉(zhuǎn)gif格式的實現(xiàn)示例

 更新時間:2019年12月10日 14:28:19   作者:Ljsxx  
這篇文章主要介紹了python3 webp轉(zhuǎn)gif格式的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

使用PIL庫,python3安裝需要使用

pip install pillow
from PIL import Image
import os
import re

imgPath = './img/'
webpReg = r'webp$'

def getAllFile (filePath):
 files = os.listdir(filePath)
 return files

def handleConversion (fileName):
 fileName = imgPath + fileName
 print('fileName--->', fileName)
 saveName = fileName.replace('webp', 'gif')
 print('saveName--->', saveName)
 im = Image.open(fileName)
 im.save(saveName, 'gif', save_all=True)

def main():
 files = getAllFile('./img')
 for fileName in files:
  gifName = fileName.replace('.webp', '.gif')
  # webp格式且未轉(zhuǎn)過的才需要轉(zhuǎn)
  if re.findall(webpReg, fileName) != [] and (gifName not in files):
   handleConversion(fileName)

if __name__ == '__main__':
 main()

圖片文件放在img目錄下

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論