mirror of
https://github.com/NanjingForestryUniversity/supermachine--tomato-passion_fruit.git
synced 2025-11-09 06:44:02 +00:00
14 lines
500 B
Python
14 lines
500 B
Python
import os
|
|
from PIL import Image
|
|
|
|
def convert_images(directory):
|
|
for filename in os.listdir(directory):
|
|
if filename.endswith('.png'):
|
|
filepath = os.path.join(directory, filename)
|
|
with Image.open(filepath) as img:
|
|
if img.mode == 'RGBA':
|
|
img = img.convert('RGB')
|
|
img.save(filepath)
|
|
|
|
# 调用函数,替换为你的目录路径
|
|
convert_images(r'D:\同步盘\project\Tomato\20240410RGBtest2\super-tomato\images') |