Tre*_*242 3 python image python-imaging-library rgba
完全像标题.我拍摄模式为"1"的单波段图像并使用它打开
image = Image.open("picture.tif")
Run Code Online (Sandbox Code Playgroud)
然后我尝试将其转换为RGBA
image.convert("RGBA")
Run Code Online (Sandbox Code Playgroud)
然后每当我检查它的模式使用
print(image.mode)
Run Code Online (Sandbox Code Playgroud)
我知道它仍然是"1".我甚至尝试使用"L"(这是另一种单波段图像模式),但仍然没有运气.无论我做什么,它都不会转换.仅在网上搜索似乎显示从"RGBA"转换为"1",但我无法找到任何相关的方法.是否有任何方法(甚至在Python之外)将1位深度图像转换为RGBA?
救命?
image.convert 不会更改图像的模式,它会使用新模式返回新图像.
image = image.convert("RGBA")
Run Code Online (Sandbox Code Playgroud)
从文档:
除非另有说明,否则所有方法都会返回Image类的新实例,并保留生成的图像.