简体   繁体   English

如何使用Python获取TIFF图像的文本图章

[英]How to get Text Stamps of a TIFF Image using Python

When using TIFF-Editor, you can add Stamps to tiff images (Basically just Text). 使用TIFF-Editor时,可以将图章添加到tiff图像中(基本上只是文本)。 You can also edit and remove stamps someone else added before. 您还可以编辑和删除以前添加的其他人的图章。

Is there a way to read the stamps an image contains via python? 有没有办法通过python读取图像包含的邮票? The objective is to automate a process where a person reads those stamps and decides where to direct the file to. 目的是使一个人阅读这些图章并决定将文件定向到何处的过程自动化。

I already tried opening the files and get some META data about them via exifRead. 我已经尝试打开文件,并通过exifRead获取有关它们的一些META数据。 It doesn't tell anything about the stamps though. 它并没有透露任何有关邮票的信息。

import exifread
f = open("src.tif", 'rb')
tags = exifread.process_file(f)
print(tags)

Works with python 3.6, using Pillow. 使用Pillow与python 3.6一起使用。

from PIL import Image
from PIL.TiffTags import TAGS

with Image.open('image.tiff') as img:
    meta_dict = {TAGS[key] : img.tag[key] for key in img.tag}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM