批量将RGBA图片转换成RGB格式
生活随笔
收集整理的這篇文章主要介紹了
批量将RGBA图片转换成RGB格式
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
首先,下面的代碼圖片必須是從0開始到21結束,比如:0.jpg等,可以看我的上一篇博客,怎么把圖片的文件名從0開始進行命名。之后,就是復制粘貼就可以。
轉換后保存的文件夾為:work_path_new
from PIL import Image #-- coding: UTF-8 --work_path = r'C:\Users\Administrator\Desktop\project\3' work_path_new = r"C:\Users\Administrator\Desktop\project\3_new" count = "0"for i in range(21):print(work_path)im = Image.open(work_path+"\\"+count+".jpg")print(im)#此時返回一個新的image對象,轉換圖片模式image=im.convert('RGB')#調用save()保存image.save(work_path_new+"\\"+count+".jpg")count = int(count)count = count + 1count = str(count)總結
以上是生活随笔為你收集整理的批量将RGBA图片转换成RGB格式的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Mentor许可不够
- 下一篇: D3D处理2D图像: NV12格式及其转