问题
Exactly like the title. I take a single-band image of mode "1" and open it using
image = Image.open("picture.tif")
I then try to convert it to RGBA with
image.convert("RGBA")
And then whenever I check the mode of it using
print(image.mode)
I get that it's still "1". I've even tried this using "L" (which is another single-band image mode) and still no luck. No matter what I do, it won't convert. Searching the web only seems to reveal converting from "RGBA" to "1" but I haven't been able to find anything about the other way around. Is there ANY way (even outside Python) to convert 1 bit deep images to RGBA?
Help?
回答1:
image.convert
doesn't change the mode of the image, it returns a new image with the new mode.
image = image.convert("RGBA")
From the documentation:
Unless otherwise stated, all methods return a new instance of the Image class, holding the resulting image.
来源:https://stackoverflow.com/questions/12270163/python-pil-how-do-i-convert-1-bit-deep-images-to-rgba