We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
JPEG的EXIF段为 clible长度,并包含TIFF结构。虽然从技术上讲可以在不重写容器文件的情况下更改EXIF(TIFF)数据,但这会限制您仅更改字段的选择,或者非常小心,以免字符串成长等。实际上,这不是很有用。
取而代之的是,我认为编辑EXIF元数据的大多数软件都会替换整个EXIF段,并且 copy 来自原始文件AS-IS的其他段。由于JPEG互换格式基于细分市场,因此相对容易做到这一点。
我相信MP4格式的情况相似。
类似于(伪代码):
因此,是的,如果您的计划应该可以起作用(尽管从技术上讲,它仍然“重写整个文件”)。
我完成了一些具有相似功能的低级元数据类,这可能是一个起点,但不要开箱即用。参见JPEGSegmentUtil and
但是,如果您的目标是操作后文件将是相同的,那么仅复制文件似乎更简单,更安全。
PS:还值得注意的是,EXIF数据中的某些字段与图像数据的解释(颜色空间,方向,维度)直接相关。因此,您可能应该仅复制字段的子集,或确保图像数据否则相同。
The Exif segment of a JPEG is variable length, and contains a TIFF structure. While it's technically possible to change Exif (TIFF) data without rewriting the container file, this limits you to change only a selection of fields, or be very careful so that strings don't grow etc.. In practice, this is not very useful.
Instead, I think most software that edits Exif metadata will replace the entire Exif segment, and copy the other segments from the original file as-is. As the JPEG interchange format is based on segments, this is relatively easy to do.
I believe the situation is similar for the MP4 format.
Something like (pseudo code):
So, yes, if this your plan, that should work (it will still technically "rewrite the whole file" though).
I have made a few low-level metadata classes with similar functionality that could be helpful as a starting point, but don't provide this out of the box. See JPEGSegmentUtil and JPEGSegmentImageInputStream.
However, if you goal is that the files will be identical after the operation, just copying the file seems a lot simpler and safer.
PS: It's also worth noting that some fields in the Exif data is directly related to the interpretation of the image data (color space, orientation, dimensions). So you should probably copy only a subset of fields, or make sure the image data is otherwise the same.