我需要用 4 个通道保存 tiff 图像,特别是 R、G、B 和 A 通道。
当我尝试使用Image.save()4 个通道保存 tiff 时,生成的图像是 RGBA 图像,但是在 Photoshop 中检查 tiff 时,唯一的通道是 RGB,没有 Alpha。有没有办法将 4 个通道合并到一个 RGBA 图像中,并带有第 4 个通道(一个单独的 alpha 通道)?
以下是我尝试过的示例
from PIL import Image
# import image A
inputImageA = Image.open(input_imageA_path)
# import image B
inputImageB = Image.open(input_imageB_path)
# split channels
R, G, B, A = inputImageA.split()
alpha_channel = inputImageA.split()[-1]
# merge 4 channels back into a single image
outputImage = Image.merge("RGBA", [R,G,B,alpha_channel])
# save the new image …Run Code Online (Sandbox Code Playgroud)