我试图读取并保存一个带有一些附加标记的tiff文件,当我创建一个新的图像,但当我打开一个图像,然后试图写回一些元标记时,它是不起作用的(图像可以被写入,但它将保持原标记不变,没有任何变化)。在
我附上了我的测试代码,感谢任何帮助!在
from PIL import Image, TiffImagePlugin
def test_custom_metadata():
img = Image.open('myimage.tif')
info = TiffImagePlugin.ImageFileDirectory()
CustomTagId = 37000
info[CustomTagId] = 6
info.tagtype[CustomTagId] = 3 # 'short' TYPE
Image.DEBUG=True
TiffImagePlugin.WRITE_LIBTIFF = False # Set to True to see it break.
img.save('./temp2.tiff', tiffinfo = info)
test_custom_metadata()
对于感兴趣的人:
C/C++ method to add custom tag for tiff file
那将完全解决问题
以下内容适用于2.3版枕头:
在当前文件夹中使用
input.tiff
运行时,将打印my special tiff tag
。在我的理解是,只有在不使用libtiff编写文件时,这才有效。使用libtiff时,将忽略自定义标记。在
相关问题 更多 >
编程相关推荐