我有一个模式为1的多帧tiff图像,我想将其转换为模式为'RGB'的多帧tiff。它只在输出中保存一个帧。我错过什么了吗?
def q(file_path='test.tiff'):
with Image.open(file_path) as image:
if image.mode != 'RGB':
n = image.convert('RGB')
n.save(fp='new.tiff', format="TIFF", save_all=True, compression="None")
return
您需要遍历帧序列。看到这里。
以上链接的代码:
from PIL import Image
with Image.open("animation.gif") as im:
im.seek(1) # skip to the second frame
try:
while 1:
im.seek(im.tell() + 1)
# do something to im
except EOFError:
pass # end of sequence