python 将图片转换成RGB
python 将图片转换成RGB
import os from PIL import Image # 填入图片所在文件夹的路径 img_path = 'E:\chengxu\CV\dataset_hat_person\hat' # 获取该路径下的图片 img_all = os.listdir(img_path) for i in img_all: image_path = img_path + "\\" + i img = Image.open(image_path) if (img.mode != 'RGB'): print(i) img = img.convert("RGB") img.save(img_path + '\\' + i)
注:转换完之后,会覆盖原图!!!