JPG - 如何从 ICC 配置文件部分 APP2 读取/提取数据
JPG - how to read / extract data from ICC profile section APP2
我有一个 JPG 文件,我从中提取了 ICC 颜色配置文件部分 (APP2)。但是,我不知道如何从中提取相关数据,如白点、黑点、RGB 设置等。我什至找不到部分描述。
我发现了这个:https://exiftool.org/ 提供了 API,但我不能使用它,因为它是 运行 后台进程的包装器。
包含 ICC 配置文件的 APP2 段的整体格式在 ICC 规范的附录 B.4 中进行了描述:
The JPEG standard (ISO/IEC 10918-1[2]) supports application specific data segments. These segments may
be used for tagging images with ICC profiles. The APP2 marker is used to introduce the ICC profile tag. Given
that there are only 15 supported APP markers, there is a chance of many applications using the same marker.
ICC tags are thus identified by beginning the data with a special null terminated byte sequence,
“ICC_PROFILE”.
The length field of a JPEG marker is only two bytes long; the length of the length field is included in the total.
Hence, the values 0 and 1 are not legal lengths. This would limit the maximum data length to 65 533. The
identification sequence would lower this even further. As it is quite possible for an ICC profile to be longer than
this, a mechanism is required to break the profile into chunks and place each chunk in a separate marker. A
mechanism to identify each chunk in sequence order is therefore necessary.
The identifier sequence is followed by one byte indicating the sequence number of the chunk (counting starts
at 1) and one byte indicating the total number of chunks. All chunks in the sequence should indicate the same
total number of chunks. The 1-byte chunk count limits the size of embeddable profiles to 16 707 345 bytes.
因此,要获得可用的配置文件,您需要从每个块中剥离前导“ICC_PROFILE”、长度字段和序列号,然后将所有块按顺序放在一起。
从那里开始,您需要查看 ICC 的第 7 节以了解详细信息。一些数据(例如,光源的 XYZ)很容易在配置文件 header 中找到。其他人将需要根据配置文件中的数据计算(在某些情况下可能相当 non-trivial)。
参考
我有一个 JPG 文件,我从中提取了 ICC 颜色配置文件部分 (APP2)。但是,我不知道如何从中提取相关数据,如白点、黑点、RGB 设置等。我什至找不到部分描述。
我发现了这个:https://exiftool.org/ 提供了 API,但我不能使用它,因为它是 运行 后台进程的包装器。
包含 ICC 配置文件的 APP2 段的整体格式在 ICC 规范的附录 B.4 中进行了描述:
The JPEG standard (ISO/IEC 10918-1[2]) supports application specific data segments. These segments may be used for tagging images with ICC profiles. The APP2 marker is used to introduce the ICC profile tag. Given that there are only 15 supported APP markers, there is a chance of many applications using the same marker. ICC tags are thus identified by beginning the data with a special null terminated byte sequence, “ICC_PROFILE”. The length field of a JPEG marker is only two bytes long; the length of the length field is included in the total. Hence, the values 0 and 1 are not legal lengths. This would limit the maximum data length to 65 533. The identification sequence would lower this even further. As it is quite possible for an ICC profile to be longer than this, a mechanism is required to break the profile into chunks and place each chunk in a separate marker. A mechanism to identify each chunk in sequence order is therefore necessary. The identifier sequence is followed by one byte indicating the sequence number of the chunk (counting starts at 1) and one byte indicating the total number of chunks. All chunks in the sequence should indicate the same total number of chunks. The 1-byte chunk count limits the size of embeddable profiles to 16 707 345 bytes.
因此,要获得可用的配置文件,您需要从每个块中剥离前导“ICC_PROFILE”、长度字段和序列号,然后将所有块按顺序放在一起。
从那里开始,您需要查看 ICC 的第 7 节以了解详细信息。一些数据(例如,光源的 XYZ)很容易在配置文件 header 中找到。其他人将需要根据配置文件中的数据计算(在某些情况下可能相当 non-trivial)。