简体   繁体   English

TIFF 文件中的隐藏元数据

[英]Hidden metadata in TIFF files

I'm using a proprietary software to record and export microscope images as TIFF files.我正在使用专有软件将显微镜图像记录和导出为 TIFF 文件。 When I load the TIFF files in the imaging software, I have access to all imaging settings at the time of recording.当我在成像软件中加载 TIFF 文件时,我可以访问录制时的所有成像设置。 However, I don't have the software on my working computer, so I'm trying to access the metadata in another way.但是,我的工作计算机上没有该软件,因此我尝试以另一种方式访问​​元数据。

I have tried using some online TIFF viewers that display TIFF tags and I've tried the OME metadata viewer using Bio-Formats .我尝试使用一些显示 TIFF 标签的在线 TIFF 查看器,并且我尝试过使用Bio-Formats的 OME 元数据查看器。 However, both of them show only a part of the metadata that is available through my imaging software.但是,它们都只显示了可通过我的成像软件获得的部分元数据。 I have also tried accessing the data through pillow to no avail.我也尝试通过枕头访问数据无济于事。

from PIL import Image
from PIL.TiffTags import TAGS

def main():
    with Image.open('image.tif') as img:
        for key in img.tag:
            print(key)
            try:
                print(TAGS[key])
            except:
               print("unknown key")

            print(img.tag[key])

My questions are: Why is the metadata missing, where is it stored, and how can I access it?我的问题是:为什么元数据丢失,它存储在哪里,以及如何访问它? I'm open to using C++, MatLab, or Python libraries if they can get me what I need.如果 C++、MatLab 或 Python 库能够满足我的需求,我愿意使用它们。

You may be able to use the LEADTOOLS SDK to read the metadata inside your TIFF files.您可以使用 LEADTOOLS SDK 来读取 TIFF 文件中的元数据。 The ReadTags() method offers the ability to read any TIFF tag in the file whether it's a private tag or not. ReadTags() 方法提供了读取文件中任何 TIFF 标签的能力,无论它是否是私有标签。

The API allows you to enumerate all of the tags in the file, both private and standard, in order to find the tags that you are looking for. API 允许您枚举文件中的所有标签,包括私有标签和标准标签,以便找到您要查找的标签。 https://www.leadtools.com/help/sdk/v22/main/clib/working-with-private-tiff-tags.html https://www.leadtools.com/help/sdk/v22/main/clib/working-with-private-tiff-tags.html

See sample code snippet below (Note code snippet is written in C# but APIs for C++ and Java exist too):请参阅下面的示例代码片段(注意代码片段是用 C# 编写的,但也存在用于 C++ 和 Java 的 API):

string tifFile = @"FILE PATH TO TIFF";

using (RasterCodecs _codecs = new RasterCodecs())
{
    CodecsImageInfo _info = _codecs.GetInformation(tifFile, false);
    RasterImageFormat _format = _info.Format;
    IList<RasterTagMetadata> _tags = null;
    if (RasterCodecs.TagsSupported(_format))
    {
       // If you have a multipage TIFF you just enumerate through the pages and pass in the page number in the second param below.
        _tags = _codecs.ReadTags(tifFile, 1);
    }
    else
        return;

    if (_tags != null)
    {
        foreach (RasterTagMetadata tag in _tags)
        {
            Console.WriteLine($"Id: 0x{tag.Id.ToString("X")}, data length: {tag.GetData().Length}");
        }
    }
}

https://i.stack.imgur.com/rcEY9.png https://i.stack.imgur.com/rcEY9.png

Feel free to also take a look at the Tutorial links below for more information.请随时查看下面的教程链接以获取更多信息。 https://www.leadtools.com/help/sdk/v22/tutorials/cdll-read-and-write-tiff-tags-and-comments.html https://www.leadtools.com/help/sdk/v22/tutorials/cdll-read-and-write-tiff-tags-and-comments.html

DISCLOSURE: I am an employee of the company offering this toolkit.披露:我是提供此工具包的公司的一名员工。

Why is the metadata missing为什么元数据丢失

Note that TIFF had multiple versions and also additional specifications for example TIFF/EP or TIFF/IT .请注意, TIFF有多个版本以及其他规范,例如TIFF/EPTIFF/IT Moreover TIFF does support so-called Private tags, according to loc.gov此外,根据loc.gov 的说法TIFF确实支持所谓的私人标签

An organization might wish to store information meaningful to only that organization .组织可能希望存储仅对该组织有意义的信息。 . . . . . . Tags numbered 32768 or higher, sometimes called private tags, are reserved for that purpose.编号为 32768 或更高的标签,有时称为私有标签,是为此目的而保留的。 Upon request, the TIFF administrator .根据要求,TIFF 管理员 . . . . . will allocate and register one or more private tags for an organization .将为一个组织分配和注册一个或多个私有标签。 . . . . . . You do not need to tell the TIFF administrator what you plan to use them for, but giving us this information may help other developers to avoid some duplication of effort.您无需告诉 TIFF 管理员您打算将它们用于什么目的,但向我们提供此信息可能有助于其他开发人员避免一些重复工作。

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

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