嗨,我在文件夹 a 中有一个包含彩色图像的文件夹,我想将它们更改为灰度图像并保存在文件夹 b 中
from PIL import Image
import os
# Changing image to gray and scaling to 256x128
WORK_DIR = 'D:/folder/data/' #working folder
source = WORK_DIR + 'a'
target = WORK_DIR +'b'
for dirpath, filenames in os.walk(source):
for file in filenames:
image_file = Image.open(os.path.join(dirpath, file))
image_file.draft('L', (256, 128)) #convert to gray and 256x128
image_file.save(os.path.join(target, file))
我收到以下错误,我不确定它是什么意思,我该如何解决?
----> 7 for dirpath, filenames in os.walk(source):
8 for file in filenames:
9 image_file = Image.open(os.path.join(dirpath, file))
ValueError: too many values to unpack (expected 2)
谢谢!