Debian Codegraph @

html/commentary.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
3 <html>
4 <head>
5 <title>Commentary on Meta Information Formats</title>
6 <link rel=stylesheet type='text/css' href='style.css' title='Style'>
7 <style type="text/css">
8 <!--
9 a.ref { text-decoration: none; font-size: x-small;
10 font-weight: normal; vertical-align: super; }
11 .norm { font-weight: normal }
12 -->
13 </style>
14 </head>
15 <body>
16 <div class='index'>
17 <b>What sucks:</b>
18 <br><a href="#EXIF">EXIF / TIFF</a>
19 <br><a href="#Maker">EXIF Maker notes</a>
20 <br><a href="#JPEG">JPEG</a>
21 <br><a href="#IPTC">IPTC IIM</a>
22 <br><a href="#XMP">XMP</a>
23 <br><a href="#PDF">PDF</a>
24 <br><a href="#PNG">PNG</a>
25 <br><a href="#PICT">PICT</a>
26 <br><a href="#FlashPix">FlashPix</a>
27 <br><a href="#DICOM">DICOM</a>
28 <br><a href="#AVCHD">AVCHD</a>
29 <br><a href="#ISO">ISO</a>
30 <br><b>What doesn't:</b>
31 <br><a href="#CRW">CRW (CIFF)</a>
32 <br><a href="#QuickTime">QuickTime</a>
33 <br><a href="#MIE">MIE</a>
34 </div>
35
36 <h2 class='up'>Commentary on Meta Information Formats<br>
37 <span class='sm'>(or <i>"Why this or that Format Sucks"</i>)</span></h2>
38
39 <a name='EXIF'></a>
40 <h3>EXIF / TIFF</h3>
41 <p>EXIF uses the TIFF format to store information. The biggest problem with
42 this format is that all pointers are absolute (ie. relative to the start of
43 the file). This means that the pointers need fixing up if the position of
44 any information changes. This is significant because pointers are often
45 hidden inside proprietary structures which should remain opaque (such as
46 maker notes). The result is that some EXIF information is easily corrupted
47 when editing a file. This problem is ignored by many software packages.
48 Much effort was required in the development of ExifTool to avoid the loss of
49 information such as this.</p>
50
51 <p>A significant problem is that an IFD (image file directory) pointer has
52 the same format code as a long integer, so information in any non-recognized
53 IFD is lost when the image is rewritten. There is a seldom-used format
54 code of 13 that has been proposed to indicate an IFD, but this is not part
55 of the EXIF/TIFF specification and is not in common usage. <i class=lt>[Hey!
56 Olympus has just started using this code for the IFD's in the maker notes of
57 their new Camera models! - 2007/03/08]</i></p>
58
59 <p>Also, it was wrong to specify a count instead of a size for each
60 directory entry because this makes it impossible to add new format types
61 without requiring that older readers simply discard data of unknown type
62 (since the data size isn't known, the old readers don't know how to copy the
63 data).</p>
64
65 <p>All these shortcomings make TIFF a very non-extensible format which by
66 design will result in the loss of non-standard information.</p>
67
68 <p>And we don't learn from our mistakes (OK, maybe some of us can, but
69 apparently not big corporations like Adobe or Microsoft), because the new
70 DNG and WDP formats are TIFF-based too.</p>
71
72 <p>The EXIF specification also has some significant shortcomings to add to the
73 TIFF problems, like minimal special character abilities, no language support,
74 and no way to specify time zone.</p>
75
76 <a name='Maker'></a>
77 <h3>EXIF Maker Notes</h3>
78 <p>Maker notes are a can of worms. The EXIF specification unfortunately
79 made no mention about the information format of the maker notes. If
80 properly designed, the specification would have provided a maker note IFD
81 tag to allow IFD-style maker notes to be used. Many manufacturers
82 implemented it this way, but each with a different technique and many with
83 <a href="idiosyncracies.html">odd quirks</a>. This deficiency combined with
84 problems in the TIFF (EXIF) format mean that most software will quite
85 unknowingly scramble your maker notes when an image is rewritten. To
86 prevent this, specific knowledge about files written by individual
87 manufacturers is necessary, and of course the manufacturers are not prone to
88 divulging this information to the public so it must all be reverse
89 engineered.</p>
90
91 <p>The official TIFF recommendation is to delete unknown information when
92 rewriting an image<a class=ref href="#ref1">[1]</a>, and this irresponsible
93 strategy has been adopted by some applications such as Adobe Photoshop,
94 resulting in a total loss of maker note information. This is very
95 unfortunate because even corrupted maker notes contain useful information,
96 and smart utilities (like ExifTool) are often able to recover the
97 information from damaged maker notes.</p>
98
99 <a name='JPEG'></a>
100 <h3>JPEG</h3>
101 <p>The JPEG format acts only as a container for meta information, and
102 defines no meta information format itself. But it sucks just a as a
103 container format because it limits the maximum contiguous block size to
104 64kB. This causes problems because many cameras store more than 64kB of
105 additional information in their JPEG images. Usually, this is due to the
106 medium-sized JPEG image that many cameras embed for preview purposes. It
107 would have been nice if there was a standard way to embed this preview in
108 JPEG images (without the 64kB limitation). <i class=lt>[Update: In February
109 2009 CIPA released the MPF format specification which allows storage of
110 preview images larger than 64kB, but unfortunately this specification
111 <a href="standards.html#MPF">has problems of its own</a>.]</i></p>
112
113 <p>Aside: The EXIF specification could have easily allowed the information
114 to span multiple JPEG segments, which would have been smart, but still wouldn't
115 have solved the problem entirely since it could result in a non-contiguous
116 preview image (this would be a problem for cameras since they typically want to
117 use this image for quick review of pictures, and re-mapping the image into a
118 contiguous memory space would be costly). <i class=lt>[According to the November
119 2014 XMP specification (part 3, page 13), Adobe allows multi-segment EXIF, and
120 this is supported by ExifTool 10.97 and later.]</i></p>
121
122 <a name='IPTC'></a>
123 <h3>IPTC IIM</h3>
124 <p>IPTC IIM earns a few points because it is the easiest to process of the
125 common meta information formats. However, the format is overly restrictive
126 and not very extensible. Format information and human-readable tag names
127 are not part of the specification, so it is not possible to meaningfully
128 interpret unknown values. Also, there are many interdependencies between
129 tags that make it very annoying for writing, and the special character
130 support is ill-conceived.</p>
131
132 <a name='XMP'></a>
133 <h3>XMP</h3>
134 <p>The XMP format is a good example of a designed-by-committee
135 specification. It is based on XML, which is much more complicated than
136 necessary and tries to make everyone happy by providing a multitude of
137 format styles and features (shorthand format, etc, etc). This makes it very
138 difficult to properly implement the complete specification. Not even the
139 Adobe software supports all of the format options of their own XMP
140 specification. And the format is exceedingly verbose, wasting disk space,
141 bandwidth and time.</p>
142
143 <p>Also, XMP only supports textual information. Binary information must be
144 text-encoded if stored in XMP. This makes it very bulky, slow and
145 completely unsuitable for storage of binary information.</p>
146
147 <p>Mainly because of the complexity of the specification, and despite
148 Adobe's best efforts, XMP still isn't very well supported by meta
149 information editing tools. The best hope for small application developers
150 is to link against an off-the-shelf XMP or XML library. Apparently Adobe
151 realizes this and is now providing an XMP development kit, but this solution
152 is only useful for those platforms and computer languages that they choose
153 to support.</p>
154
155 <a name='PDF'></a>
156 <h3>PDF</h3>
157 <p>...and I thought XMP was too complicated. PDF is just insane. Because
158 of this, it is unlikely that ExifTool will ever support this format for
159 writing. <i class=lt>[Dec. 18, 2007 Update: I have just added PDF write support
160 using the incremental update feature of PDF. It was still a bit of work, but
161 somewhat simpler (and MUCH faster!) than rewriting the entire PDF. But there
162 are disadvantages: The resulting PDF is not "linearized", and there are privacy
163 and security issues with leaving old metadata in the file.]</i></p>
164
165 <a name='PNG'></a>
166 <h3>PNG</h3>
167 <p>PNG sucks because meta information can be stored only in text format.
168 This was a huge mistake, and as a work-around software (eg. ImageMagick)
169 must encode binary information in ASCII-hex, then compress it to offset the
170 increase in size, and store it as a compressed text block. This adds
171 unnecessary complexity, greatly slows down processing, and makes it much
172 harder to develop software which supports PNG meta information.
173 <i class=lt>[July 2017: PNG adopts eXIf chunk to allow EXIF metadata to be
174 stored in native binary format. This is useful, but still doesn't allow storage
175 of arbitrary binary metadata.]</i></p>
176
177 <a name='PICT'></a>
178 <h3>PICT</h3>
179 <p>The PICT format just plain sucks. It is one of the worst-designed image
180 formats in existence, second only to FlashPix. I don't believe that it was
181 originally designed as a file format. Instead it appears to have emerged
182 from the internal Apple QuickDraw structures. The files are not designed to
183 be processed by any software other than the Mac OS. Intimate knowledge of
184 the QuickDraw structures is required just to parse the PICT image, even if
185 the reader doesn't care about the contained information. Because of this,
186 PICT images are very fragile and a simple data error or programming bug will
187 invalidate an entire image. Possibly for these reasons the PICT format
188 never gained popularity outside the Apple world. Also, the concept of meta
189 information is all but ignored in the PICT design.</p>
190
191 <a name='FlashPix'></a>
192 <h3>FlashPix</h3>
193 <p>Oh. My. God. Don't get me started on this one. Let's just say that basing
194 an image file format on the File Allocation Table (FAT) structure of a floppy
195 disk with fixed 512-byte sectors is monumentally idiotic. Microsoft Word,
196 Excel and PowerPoint documents also use this insane format.</p>
197
198 <a name='DICOM'></a>
199 <h3>DICOM Medical Images</h3>
200 <p>The DICOM format is reasonably well designed. The UID's are cumbersome,
201 but achieve their purpose. The biggest bungle in the design is the implicit
202 VR syntax, which presumably exists for historical reasons to provide
203 backward compatibility with pre-existing ACR-NEMA images. The DICOM
204 specification document is horrible and obviously written by committee, and
205 was possibly the single largest impediment to implementing support for this
206 format.</p>
207
208 <p>Technical: The files would be easier to parse if the transfer syntax
209 became effective immediately after the transfer syntax data element instead
210 of at the end of the meta information group. Also, the deflated data should
211 have contained the zlib header, as in PNG and PDF images. This would make
212 it easier to read and allow CRC validation of the datastream. -- Can you
213 tell I wrote this just after adding DICOM support to ExifTool?</p>
214
215 <a name='AVCHD'></a>
216 <h3>AVCHD (.M2TS) <span class='sm norm'><i class=lt>(added 2009-10-29)</i></span></h3>
217 <p>This format is used in .M2TS video files (and Blu-Ray HD DVD's). It is
218 painfully obvious that this was never designed as a storage format. It uses
219 MPEG-2 transport stream (M2TS) container, which is a communications protocol
220 and never should have been used for storage. The M2TS format is based on a
221 188-byte packet size which makes no sense for modern filesystems. And to
222 make things worse, metadata in AVCHD files is stored in the H.264 video
223 stream (!!) which uses insane and convoluted data structures such as the
224 variable-bit-length exponential-Golomb which are painful and inefficient to
225 parse in software, and as far as I can tell the format for the metadata
226 stored in these streams is proprietary and undocumented.</p>
227
228 <a name='ISO'></a>
229 <h3>ISO Considered Harmless</h3>
230 <p>This is not a meta information format, but since many format
231 specifications are imprisoned by the ISO it deserves mentioning...</p>
232
233 <p>In my experience, the International Standards Organization is extremely
234 counter-productive. Their goal is to promote standardization, but by
235 charging too much money for copies of the standards documents they defeat
236 their own purpose. The effect is that small companies and individuals
237 developing software (including open source software such as ExifTool) do not
238 have access to the official standard. Instead, software is often based on
239 old, obsolete documents or drafts which are sometimes publicly available, or
240 on 3rd party descriptions which are often incomplete. To sum things up: ISO
241 sucks.</p>
242
243 <hr>
244 <h2>OK. So all those formats suck. What doesn't?</h2>
245
246 <a name='CRW'></a>
247 <h3>Canon CRW Images (CIFF format)</h3>
248 <p>This format uses a directory structure similar to TIFF, but all offsets
249 are relative and unknown information can handled properly when rewriting.
250 Because of this, it is much more extensible than TIFF, but the format is
251 still limited by 16-bit integer tag ID's among other TIFF weaknesses. It
252 isn't great, but at least it doesn't suck.</p>
253
254 <a name='QuickTime'></a>
255 <h3>QuickTime Videos</h3>
256 <p>The Apple QuickTime MOV format is very nice format. (Which is a breath
257 of fresh air after the Apple PICT travesty.) It was a smart move to use
258 this format for the MP4 specification. I would only change 2 things about
259 this format: 1) Use longer tag names instead of the current 4 characters (I
260 know that 4 characters is convenient because it can be used as an integer in
261 lookup tables, but it would be nice if the tag names were a bit more
262 meaningful). 2) Add a format code to the Atom definition so simple unknown
263 information could be decoded properly. These changes would allow some
264 unknown information to be interpreted, which would make it possible for
265 information added by 3rd parties to be useful.</p>
266
267 <p>... but there are some significant problems with the QuickTime specification:</p>
268
269 <p>0) The biggest problem with some QuickTime-based files (ie. MOV, MP4,
270 HEIC) is that atoms may store absolute offsets into the media data, and
271 these pointers are easily invalidated by editing the file. This puts a huge
272 burdon on the editing application to update all necessary pointers, and
273 makes it much, much harder than it should be to edit these files (it takes
274 significant effort to just determine which atoms may containing pointers).</p>
275
276 <p>1) The metadata organization is a mess because tags may be stored in more
277 than one location (eg. UserData vs. InfoList), and conflicting metadata
278 directories may exist, even in the same location (as written by iTunes).</p>
279
280 <p>2) The length of 'udta' text strings with language codes is written
281 incorrectly by many (most?) utilities, including Apple iTunes. The language
282 strings are supposed to use a "small integer atom format" where the first
283 two bytes give the size of the string including the length word and language
284 codes. But often the size doesn't include these 4 bytes, which sort of
285 defeats the purpose of the multiple languages because it is difficult to
286 parse past the first entry if you don't know the size.</p>
287
288 <p>3) Cameras without time zone information are forced to write date/time
289 tags as local time, even though the specification says these should be UTC.
290 This leads to an unresolvable inconsistency in the time offset because
291 one can not distinguish between these two cases.</p>
292
293 <a name='MIE'></a>
294 <h3>My Format (Meta Information Encapsulation, or "MIE")</h3>
295 <p>Now it is time to put my money where my mouth is: I have designed a
296 format which doesn't suck. It is called "MIE", which stands for Meta
297 Information Encapsulation.</p>
298
299 <p>The MIE format is hierarchical like QuickTime, but it uses meaningful tag
300 names and specifies a data format for all values. As well, this format
301 offers a number of other features:</p>
302
303 <ul>
304 <li>Can be used as a wrapper around any type of file, as a trailer appended
305 to other formats, or as a stand-alone meta information format
306 <li>Extensible
307 <li>Compact
308 <li>Meaningful tag ID's
309 <li>Streamable (and single-pass writing possible)
310 <li>Relocatable data elements (ie. no fixed offsets)
311 <li>Relatively simple to implement reader/writer
312 <li>Supports large data lengths (up to 4GB*4GB)
313 <li>Localized text feature
314 <li>Built-in support for numerical units of measure
315 <li>Multiple documents in a single file
316 </ul>
317
318 <p>The specification for this format can be found
319 <a href="MIE1.1-20070121.pdf">here</a>, and is implemented in
320 <a href="http://search.cpan.org/dist/Image-ExifTool/lib/Image/ExifTool/MIE.pm">Image::ExifTool::MIE.pm</a></p>
321
322 <p>OK. Flame away. I can take it.</p>
323
324 <a name="refs"></a>
325 <h3>References</h3>
326
327 <ol>
328 <li><a name="ref1" href="http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf">http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf</a>, page 26</li>
329 </ol>
330
331 <hr>
332 <i>Created Nov 15, 2005</i><br>
333 <i>Last revised Feb 4, 2020</i>
334 <p class='lf'><a href="index.html">&lt;-- Back to ExifTool home page</a></p>
335 </body>
336 </html>