未验证 提交 73d21511 编写于 作者: 东方怂天 提交者: GitHub

Create Convert

上级 6c053a92
import os
from PIL import Image
def save_image(input_name, output_name):
im = Image.open(input_name)
if im.mode == "RGBA":
im.load() # required for png.split()
background = Image.new("RGB", im.size, (255, 255, 255))
background.paste(im, mask=im.split()[3]) # 3 is the alpha channel
im = background
im.save('{}.jpg'.format(output_name), 'JPEG')
image_files = []
for root, dirs, files in os.walk(r"C:\Users\EasternDay\Desktop\Pic\今年"):
print(files) # 当前路径下所有非目录子文件
for file in os.listdir(r"C:\Users\EasternDay\Desktop\Pic\今年"):
image_files.append(file)
image_names = [name for name in image_files if os.path.splitext(name)[
1] == '.webp']
for img in image_names:
save_image("C:/Users/EasternDay/Desktop/Pic/今年/" + img, "C:/Users/EasternDay/Desktop/Pic/今年/0"+ img)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册