Mode Mismatch when merging images with PIL
问题 I am passing the name of a .jpg file. def split_image_into_bands(filename): img = Image.open(filename) data = img.getdata() red = [(d[0], 0, 0) for d in data] # List Comprehension! green = [(0, d[1], 0) for d in data] blue = [(0, 0, d[2]) for d in data] img.putdata(red) img.save(os.path.splitext(filename)[0] + "_red.jpg") img.putdata(green) img.save(os.path.splitext(filename)[0] + "_green.jpg") img.putdata(blue) img.save(os.path.splitext(filename)[0] + "_blue.jpg") # Put the 3 images back