import os
from PIL import Image
# 原文件路径
folder_path = "C:/Users/m/Desktop/result/1dvdrR3/train"
extensions = [".png"]
# Iterate through the files in the folder
for filename in os.listdir(folder_path):
if any(filename.lower().endswith(ext) for ext in extensions):
file_path = os.path.join(folder_path, filename)
img = Image.open(file_path)
channels = img.mode
if channels == "RGB":
print(f"{filename} is an RGB three-channel image.")
else:
print(f"{filename} is not an RGB three-channel image.")
查看png图片是否是RGB三通道
最新推荐文章于 2024-08-04 10:18:57 发布