Annotations 使用Python向现有TIFF图像添加WANG注释&;枕头

Annotations 使用Python向现有TIFF图像添加WANG注释&;枕头,annotations,python-imaging-library,tiff,Annotations,Python Imaging Library,Tiff,问题的一部分是枕头的ReadtheDocs已经停止了,而谷歌搜索引擎对我毫无帮助 注释为“大黑”框(图章)样式 我们有一个TIFF文件和一个ANN文件。我相信注释(ANN)文件是我试图重新添加到原始TIFF文件中的TIFF注释的提取标记信息 >>> im = Image.open(test) >>> im2 = Image.open(test2) >>> meta_dict = {TAGS[key] : im2.tag[key] for ke

问题的一部分是枕头的ReadtheDocs已经停止了,而谷歌搜索引擎对我毫无帮助

注释为“大黑”框(图章)样式

我们有一个TIFF文件和一个ANN文件。我相信注释(ANN)文件是我试图重新添加到原始TIFF文件中的TIFF注释的提取标记信息

>>> im = Image.open(test)
>>> im2 = Image.open(test2)
>>> meta_dict = {TAGS[key] : im2.tag[key] for key in im2.tag.keys()}
>>> meta_dict
{'ImageWidth': (2544,), 'ImageLength': (0,), 'BitsPerSample': (1,), 'Compression': (1,), 'PhotometricInterpretation': (0,), 'StripOffsets': (0,), 'Orientation': (1,), 'SamplesPerPixel': (1,), 'RowsPerStrip': (0,), 'StripByteCounts': (0,), 'XResolution': ((300, 1),), 'YResolution': ((300, 1),), 'Wang Annotation': b'\x04\x00\x03\x00\x01\x00\x00\x00\x02\x00\x00\x00\x0c\x00\x00\x00OiGroup\x00\x0b\x00\x00\x00[Untitled]\x00\x02\x00\x00\x00\x0c\x00\x00\x00OiIndex\x00\n\x00\x00\x000\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x0c\x00\x00\x00PxVerStr\r\x00\x00\x0056.1.11.1571\x00\x02\x00\x00\x00\x0c\x00\x00\x00PxDPI\x00\x00\x00\x10\x00\x00\x00\xc8\x00\x00\x00\x01\x00\x00\x00\xc8\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x0c\x00\x00\x00PxStorag\x04\x00\x00\x00\x00\x00\x00\x00', 'ResolutionUnit': (2,), 'Software': ('Pixel Translations Inc., PIXTIFF Version 56.1.218.1571',), 'NewSubfileType': (0,)}
>>> im.tag[32932] = meta_dict["Wang Annotation"]
>>> im.save("test.tif")
>>> im.show()
通过阅读StackOverflow等,我认为上面的代码足以将注释从im2“合并”到im1?但我没有看到


你能给我一些关于我哪里出了问题的建议吗?

看来你错过了
tiffinfo
参数。尝试按如下方式保存文件:

im.save("test.tif", tiffinfo=im.tag)

您似乎遗漏了
tiffinfo
参数。尝试按如下方式保存文件:

im.save("test.tif", tiffinfo=im.tag)

您可以将第三行重写为
meta_dict={TAGS[key]:key的值,im2.tag.items()中的值
您可以将第三行重写为
meta_dict={TAGS[key]:key的值,im2.tag.items()中的值