问题描述
与标题完全一样.我拍摄模式为"1"的单波段图像,并使用
Exactly like the title. I take a single-band image of mode "1" and open it using
image = Image.open("picture.tif")
然后我尝试将其转换为RGBA
I then try to convert it to RGBA with
image.convert("RGBA")
然后每当我使用
print(image.mode)
我知道它仍然是"1".我什至尝试过使用"L"(这是另一种单波段图像模式),但还是没有运气.不管我做什么,都不会转换.搜索网络似乎只显示了从"RGBA"到"1"的转换,但是我无法找到任何其他方式.是否有任何方法(甚至在Python之外)也可以将1位深的图像转换为RGBA?
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?
帮助?
推荐答案
image.convert
不会更改图像的模式,它将返回具有新模式的新图像.
image.convert
doesn't change the mode of the image, it returns a new image with the new mode.
image = image.convert("RGBA")
来自文档:
这篇关于Python PIL如何将1位深的图像转换为RGBA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!