1Image::ExifTool::MIE(3)User Contributed Perl DocumentatioInmage::ExifTool::MIE(3)
2
3
4
6 Image::ExifTool::MIE - Read/write MIE meta information
7
9 This module is used by Image::ExifTool
10
12 This module contains routines required by Image::ExifTool to read and
13 write information in MIE files.
14
16 MIE stands for "Meta Information Encapsulation". The MIE format is an
17 extensible, dedicated meta information format which supports storage of
18 binary as well as textual meta information. MIE can be used to encap‐
19 sulate meta information from many sources and bundle it together with
20 any type of file.
21
22 Features
23
24 Below is very subjective score card comparing the features of a number
25 of common file and meta information formats, and comparing them to MIE.
26 The following features are rated for each format with a score of 0 to
27 10:
28
29 1) Extensible (can incorporate user-defined information).
30 2) Meaningful tag ID's (hint to meaning of unknown information).
31 3) Sequential read/write ability (streamable).
32 4) Hierarchical information structure.
33 5) Easy to implement reader/writer/editor.
34 6) Order of information well defined.
35 7) Large data lengths supported: >64kB (+5) and >4GB (+5).
36 8) Localized text strings.
37 9) Multiple documents in a single file.
38 10) Compact format doesn't squander disk space or bandwidth.
39 11) Compressed meta information supported.
40 12) Relocatable data elements (ie. no fixed offsets).
41 13) Binary meta information (+7) with variable byte order (+3).
42 14) Mandatory tags not required (an unecessary complication).
43 15) Append information to end of file without editing.
44
45 Feature number Total
46 Format 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Score
47 ------ --------------------------------------------- -----
48 MIE 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 150
49 PDF 10 10 0 10 0 0 10 0 10 10 10 0 7 10 10 97
50 PNG 10 10 10 0 8 0 5 10 0 10 10 10 0 10 0 93
51 XMP 10 10 10 10 2 0 10 10 10 0 0 10 0 10 0 92
52 AIFF 0 5 10 10 10 0 5 0 0 10 0 10 7 10 0 77
53 RIFF 0 5 10 10 10 0 5 0 0 10 0 10 7 10 0 77
54 JPEG 10 0 10 0 10 0 0 0 0 10 0 10 7 10 0 67
55 EPS 10 10 10 0 0 0 10 0 10 0 0 5 0 10 0 65
56 CIFF 0 0 0 10 10 0 5 0 0 10 0 10 10 10 0 65
57 TIFF 0 0 0 10 5 10 5 0 10 10 0 0 10 0 0 60
58 EXIF 0 0 0 10 5 10 0 0 0 10 0 0 10 0 0 45
59 IPTC 0 0 10 0 8 0 0 0 0 10 0 10 7 0 0 45
60
61 By design, MIE ranks highest by a significant margin. Other formats
62 with reasonable scores are PDF, PNG and XMP, but each has significant
63 weak points. What may be surprising is that TIFF, EXIF and IPTC rank
64 so low.
65
66 As well as scoring high in all these features, the MIE format has the
67 unique ability to encapsulate any other type of file, and provides a
68 non-invasive method of adding meta information to a file. The meta
69 information is logically separated from the original file data, which
70 is extremely important because meta information is routinely lost when
71 files are edited.
72
73 Also, the MIE format supports multiple files by simple concatenation,
74 enabling all kinds of wonderful features such as linear databases, edit
75 histories or non-intrusive file updates. This ability can also be
76 leveraged to allow MIE-format trailers to be added to some other file
77 types.
78
80 File Structure
81
82 A MIE file consists of a series of MIE elements. A MIE element may
83 contain either data or a group of MIE elements, providing a hierarchi‐
84 cal format for storing data. Each MIE element is identified by a
85 human-readable tag name, and may store data from zero to 2^64-1 bytes
86 in length.
87
88 File Signature
89
90 The first element in the MIE file must be an uncompressed MIE group
91 element with a tag name of "0MIE". This restriction allows the first 8
92 bytes of a MIE file to be used to identify a MIE format file. The fol‐
93 lowing table lists the two possible initial byte sequences for a MIE-
94 format file (the first for big-endian, and the second for little-endian
95 byte ordering):
96
97 Byte Number: 0 1 2 3 4 5 6 7
98
99 C Characters: ~ \x10 \x04 ? 0 M I E
100 or ~ \x18 \x04 ? 0 M I E
101
102 Hexadecimal: 7e 10 04 ? 30 4d 49 45
103 or 7e 18 04 ? 30 4d 49 45
104
105 Decimal: 126 16 4 ? 48 77 73 69
106 or 126 24 4 ? 48 77 73 69
107
108 Note that byte 1 may have one of the two possible values (0x10 or
109 0x18), and byte 3 may have any value (0x00 to 0xff).
110
111 Element Structure
112
113 1 byte SyncByte = 0x7e (decimal 126, character '~')
114 1 byte FormatCode (see below)
115 1 byte TagLength (T)
116 1 byte DataLength (gives D if DataLength < 253)
117 T bytes TagName (T given by TagLength)
118 2 bytes DataLength2 [exists only if DataLength == 255 (0xff)]
119 4 bytes DataLength4 [exists only if DataLength == 254 (0xfe)]
120 8 bytes DataLength8 [exists only if DataLength == 253 (0xfd)]
121 D bytes DataBlock (D given by DataLength)
122
123 The minimum element length is 4 bytes (for a group terminator). The
124 maximum DataBlock size is 2^64-1 bytes. TagLength and DataLength are
125 unsigned integers, and the byte ordering for multi-byte DataLength
126 fields is specified by the containing MIE group element. The SyncByte
127 is byte aligned, so no padding is added to align on an N-byte boundary.
128
129 FormatCode
130
131 The format code is a bitmask that defines the format of the data:
132
133 7654 3210
134 ++++ ---- FormatType
135 ---- +--- TypeModifier
136 ---- -+-- Compressed
137 ---- --++ FormatSize
138
139 FormatType (bitmask 0xf0):
140 0x00 - other (or unknown) data
141 0x10 - MIE group
142 0x20 - text string
143 0x30 - list of null-separated text strings
144 0x40 - integer
145 0x50 - rational
146 0x60 - fixed point
147 0x70 - floating point
148 0x80 - free space
149
150 TypeModifier (bitmask 0x08):
151 Modifies the meaning of certain FormatTypes (0x00-0x60):
152
153 0x08 - other data sensitive to MIE group byte order
154 0x18 - MIE group with little-endian byte ordering
155 0x28 - UTF encoded text string
156 0x38 - UTF encoded text string list
157 0x48 - signed integer
158 0x58 - signed rational (denominator is always unsigned)
159 0x68 - signed fixed-point
160
161 Compressed (bitmask 0x04):
162 If this bit is set, the data block is compressed using Zlib
163 deflate. An entire MIE group may be compressed, with the exception
164 of file-level groups.
165
166 FormatSize (bitmask 0x03):
167 Gives the byte size of each data element:
168
169 0x00 - 8 bits (1 byte)
170 0x01 - 16 bits (2 bytes)
171 0x02 - 32 bits (4 bytes)
172 0x03 - 64 bits (8 bytes)
173
174 The number of bytes in a single value for this format is given by
175 2**FormatSize (or 1 << FormatSize). The number of values is the
176 data length divided by this number of bytes. It is an error if the
177 data length is not an even multiple of the format size in bytes.
178
179 The following is a list of all currently defined MIE FormatCode values
180 for uncompressed data (add 0x04 to each value for compressed data):
181
182 0x00 - other data (insensitive to MIE group byte order) (1)
183 0x01 - other 16-bit data (may be byte swapped)
184 0x02 - other 32-bit data (may be byte swapped)
185 0x03 - other 64-bit data (may be byte swapped)
186 0x08 - other data (sensitive to MIE group byte order) (1)
187 0x10 - MIE group with big-endian values (1)
188 0x18 - MIE group with little-endian values (1)
189 0x20 - ASCII (ISO 8859-1) string (2,3)
190 0x28 - UTF-8 string (2,3,4)
191 0x29 - UTF-16 string (2,3,4)
192 0x2a - UTF-32 string (2,3,4)
193 0x30 - ASCII (ISO 8859-1) string list (3,5)
194 0x38 - UTF-8 string list (3,4,5)
195 0x39 - UTF-16 string list (3,4,5)
196 0x3a - UTF-32 string list (3,4,5)
197 0x40 - unsigned 8-bit integer
198 0x41 - unsigned 16-bit integer
199 0x42 - unsigned 32-bit integer
200 0x43 - unsigned 64-bit integer (6)
201 0x48 - signed 8-bit integer
202 0x49 - signed 16-bit integer
203 0x4a - signed 32-bit integer
204 0x4b - signed 64-bit integer (6)
205 0x52 - unsigned 32-bit rational (16-bit numerator then denominator) (7)
206 0x53 - unsigned 64-bit rational (32-bit numerator then denominator) (7)
207 0x5a - signed 32-bit rational (denominator is unsigned) (7)
208 0x5b - signed 64-bit rational (denominator is unsigned) (7)
209 0x61 - unsigned 16-bit fixed-point (high 8 bits is integer part) (8)
210 0x62 - unsigned 32-bit fixed-point (high 16 bits is integer part) (8)
211 0x69 - signed 16-bit fixed-point (high 8 bits is signed integer) (8)
212 0x6a - signed 32-bit fixed-point (high 16 bits is signed integer) (8)
213 0x72 - 32-bit IEEE float (not recommended for portability reasons)
214 0x73 - 64-bit IEEE double (not recommended for portability reasons) (6)
215 0x80 - free space (value data does not contain useful information)
216
217 Notes:
218
219 1. The byte ordering specified by the MIE group TypeModifier applies
220 to the MIE group element as well as all elements within the group.
221 Data for all FormatCodes except 0x08 (other data, sensitive to byte
222 order) may be transferred between MIE groups with different byte
223 order by byte swapping the uncompressed data according to the spec‐
224 ified data format. The following list illustrates the byte-swap‐
225 ping pattern, based on FormatSize, for all format types except
226 rational (FormatType 0x50).
227
228 FormatSize Change in Byte Sequence
229 -------------- -----------------------------------
230 0x00 (8 bits) 0 1 2 3 4 5 6 7 --> 0 1 2 3 4 5 6 7 (no change)
231 0x01 (16 bits) 0 1 2 3 4 5 6 7 --> 1 0 3 2 5 4 7 6
232 0x02 (32 bits) 0 1 2 3 4 5 6 7 --> 3 2 1 0 7 6 5 4
233 0x03 (64 bits) 0 1 2 3 4 5 6 7 --> 7 6 5 4 3 2 1 0
234
235 Rational values consist of two integers, so they are swapped as the
236 next lower FormatSize. For example, a 32-bit rational (FormatSize
237 0x02, and FormatCode 0x52 or 0x5a) is swapped as two 16-bit values
238 (ie. as if it had FormatSize 0x01).
239
240 2. The TagName of a string element may have an 6-character suffix to
241 indicate a specific locale. (ie. "Title-en_US", or "Key‐
242 words-de_DE").
243
244 3. Text strings are not normally null terminated, however they may be
245 padded with one or more null characters to the end of the data
246 block to allow strings to be edited within fixed-length data
247 blocks. Newlines in the text are indicated by a single LF (0x0a)
248 character.
249
250 4. UTF strings must not begin with a byte order mark (BOM) since the
251 byte order and byte size are specified by the MIE format. If a BOM
252 is found, it should be treated as a zero-width non-breaking space.
253
254 5. A list of text strings separated by null characters. These lists
255 must not be null padded or null terminated, since this would be
256 interpreted as additional zero-length strings. For ASCII and UTF-8
257 strings, the null character is a single zero (0x00) byte. For
258 UTF-16 or UTF-32 strings, the null character is 2 or 4 zero bytes
259 respectively.
260
261 6. 64-bit integers and doubles are subject to the specified byte
262 ordering for both 32-bit words and bytes within these words. For
263 instance, the high order byte is always the first byte if
264 big-endian, and the eighth byte if little-endian. This means that
265 some swapping is always necessary for these values on systems where
266 the byte order differs from the word order (ie. some ARM systems),
267 regardless of the endian-ness of the stored values.
268
269 7. Rational values are treated as two separate integers. The numera‐
270 tor always comes first regardless of the byte ordering. In a
271 signed rational value, only the numerator is signed. The denomina‐
272 tor of all rational values is unsigned (ie. a signed 32-bit ratio‐
273 nal of 0x80000000/0x80000000 evaluates to -1, not +1).
274
275 8. 32-bit fixed point values are converted to floating point by treat‐
276 ing them as an integer and dividing by an appropriate value. ie)
277
278 16-bit fixed value = 16-bit integer value / 256.0
279 32-bit fixed value = 32-bit integer value / 65536.0
280
281 TagLength
282
283 Gives the length of the TagName string. Any value between 0 and 255 is
284 valid, but the TagLength of 0 is valid only for the MIE group termina‐
285 tor.
286
287 DataLength
288
289 DataLength is an unsigned byte that gives the number of bytes in the
290 data block. A value between 0 and 252 gives the data length directly,
291 and numbers from 253 to 255 are reserved for extended DataLength codes.
292 Codes of 255, 254 and 253 indicate that the element contains an addi‐
293 tional 2, 4 or 8 byte unsigned integer representing the data length.
294
295 0-252 - length of data block
296 255 (0xff) - use DataLength2
297 254 (0xfe) - use DataLength4
298 253 (0xfd) - use DataLength8
299
300 A DataLength of zero is valid for any element except a compressed MIE
301 group. A zero DataLength for an uncompressed MIE group indicates that
302 the group length is unknown. For other elements, a zero length indi‐
303 cates there is no associated data. A terminator element must have a
304 DataLength of 0, 6 or 10, and may not use an extended DataLength.
305
306 TagName
307
308 The TagName string is 0 to 255 bytes long, and is composed of the ASCII
309 characters A-Z, a-z, 0-9 and underline ('_'). Also, a dash ('-') is
310 used to separate the language/country code in the TagName of a local‐
311 ized text string, and a units string (possibly containing other ASCII
312 characters) may be appear in brackets at the end of the TagName. The
313 TagName string is NOT null terminated. A MIE element with a tag string
314 of zero length is reserved for the group terminator.
315
316 MIE elements are sorted alphabetically by TagName within each group.
317 Multiple elements with the same TagName are allowed, even within the
318 same group.
319
320 TagNames should be meaningful. Case is significant. Words should be
321 lowercase with an uppercase first character, and acronyms should be all
322 upper case. The underline ("_") is provided to allow separation of two
323 acronyms or two numbers, but it shouldn't be used unless necessary. No
324 separation is necessary between an acronym and a word (ie. "ISOSet‐
325 ting").
326
327 All TagNames should start with an uppercase letter. An exception to
328 this rule allows tags to begin with a digit (0-9) if they must come
329 before other tags in the sort order, or a lowercase letter (a-z) if
330 they must come after. For instance, the '0Type' element begins with a
331 digit so it comes before, and the 'data' element begins with a lower‐
332 case letter so that it comes after meta information tags in the main
333 "0MIE" group.
334
335 Tag names for localized text strings have an 6-character suffix with
336 the following format: The first character is a dash ('-'), followed by
337 a 2-character lower case ISO 639-1 language code, then an underline
338 ('_'), and ending with a 2-character upper case ISO 3166-1 alpha 2
339 country code. (ie. "-en_US", "-en_GB", "-de_DE" or "-fr_FR". Note
340 that "GB", and not "UK" is the code for Great Britain, although "UK"
341 should be recognized for compatibility reasons.) The suffix is
342 included when sorting the tags alphabetically, so the default locale
343 (with no tag-name suffix) always comes first. If the country is
344 unknown or not applicable, a country code of "XX" should be used.
345
346 Tags with numerical values may allow units of measurement to be speci‐
347 fied. The units string is stored in brackets at the end of the tag
348 name, and is composed of zero or more ASCII characters in the range
349 0x21 to 0x7d, excluding the bracket characters 0x28 and 0x29. (ie.
350 "Resolution(/cm)" or "SpecificHeat(J/kg.K)".) See
351 Image::ExifTool::MIEUnits for details. Unit strings are not localized,
352 and may not be used in combination with localized text strings.
353
354 Sets of tags which would require a common prefix should be added in a
355 separate MIE group instead of adding the prefix to all tag names. For
356 example, instead of these TagName's:
357
358 ExternalFlashType
359 ExternalFlashSerialNumber
360 ExternalFlashFired
361
362 one would instead designate a separate "ExternalFlash" MIE group to
363 contain the following elements:
364
365 Type
366 SerialNumber
367 Fired
368
369 DataLength2/4/8
370
371 These extended DataLength fields exist only if DataLength is 255, 254
372 or 253, and are respectively 2, 4 or 8 byte unsigned integers giving
373 the data block length. One of these values must be used if the data
374 block is larger than 252 bytes, but they may be used if desired for
375 smaller blocks too (although this may add a few unnecessary bytes to
376 the MIE element).
377
378 DataBlock
379
380 The data value for the MIE element. The format of the data is given by
381 the FormatCode. For MIE group elements, the data includes all con‐
382 tained elements and the group terminator.
383
384 MIE groups
385
386 All MIE data elements must be contained within a group. A group begins
387 with a MIE group element, and ends with a group terminator. Groups may
388 be nested in a hierarchy to arbitrary depth.
389
390 A MIE group element is identified by a format code of 0x10 (big endian
391 byte ordering) or 0x18 (little endian). The group terminator is dis‐
392 tinguished by a zero TagLength (it is the only element allowed to have
393 a zero TagLength), and has a FormatCode of 0x00.
394
395 The MIE group element is permitted to have a zero DataLength only if
396 the data is uncompressed. This special value indicates that the group
397 length is unknown (otherwise the minimum value for DataLength is 4,
398 corresponding the the minimum group size which includes a terminator of
399 at least 4 bytes). If DataLength is zero, all elements in the group
400 must be parsed until the group terminator is found. If non-zero,
401 DataLength includes the length of all elements contained within the
402 group, including the group terminator. Use of a non-zero DataLength is
403 encouraged because it allows readers quickly skip over entire MIE
404 groups. For compressed groups DataLength must be non-zero, and is the
405 length of the compressed group data (which includes the compressed
406 group terminator).
407
408 Group Terminator
409
410 The group terminator has a FormatCode and TagLength of zero. The ter‐
411 minator DataLength must be 0, 6 or 10 bytes, and extended DataLength
412 codes may not be used. With a zero DataLength, the byte sequence for a
413 terminator is "7e 00 00 00" (hex). With a DataLength of 6 or 10 bytes,
414 the terminator data block contains information about the length and
415 byte ordering of the preceding group. This additional information is
416 recommended for file-level groups, and is used in multi-document MIE
417 files and MIE trailers to allow the file to be scanned backwards from
418 the end. (This may also allow some documents to be recovered if part
419 of the file is corrupted.) The structure of this optional terminator
420 data block is as follows:
421
422 4 or 8 bytes GroupLength (unsigned integer)
423 1 byte ByteOrder (0x10 or 0x18, same as MIE group)
424 1 byte GroupLengthSize (0x04 or 0x08)
425
426 The ByteOrder and GroupLengthSize values give the byte ordering and
427 size of the GroupLength integer. The GroupLength value is the total
428 length of the entire MIE group ending with this terminator, including
429 the opening MIE group element and the terminator itself.
430
431 File-level MIE groups
432
433 File-level MIE groups may NOT be compressed.
434
435 All elements in a MIE file are contained within a special group with a
436 TagName of "0MIE". The purpose of the "OMIE" group is to provide a
437 unique signature at the start of the file, and to encapsulate informa‐
438 tion allowing files to be easily combined. The "0MIE" group must be
439 terminated like any other group, but it is recommended that the termi‐
440 nator of a file-level group include the optional data block (defined
441 above) to provide information about the group length and byte order.
442
443 It is valid to have more than one "0MIE" group at the file level,
444 allowing multiple documents in a single MIE file. Furthermore, the MIE
445 structure enables multi-document files to be generated by simply con‐
446 catenating two or more MIE files.
447
448 Scanning Backwards through a MIE File
449
450 The steps below give an algorithm to quickly locate the last document
451 in a MIE file:
452
453 1. Read the last 10 bytes of the file. (Note that a valid MIE file
454 may be as short as 12 bytes long, but a file this length contains
455 only an an empty MIE group.)
456
457 2. If the last byte of the file is zero, then it is not possible to
458 scan backward through the file, so the file must be scanned from
459 the beginning. Otherwise, proceed to the next step.
460
461 3. If the last byte is 4 or 8, the terminator contains information
462 about the byte ordering and length of the group. Otherwise, stop
463 here because this isn't a valid MIE file.
464
465 4. The next-to-last byte must be either 0x10 indicating big-endian
466 byte ordering or 0x18 for little-endian ordering, otherwise this
467 isn't a valid MIE file.
468
469 5. The value of the preceding 4 or 8 bytes gives the length of the
470 complete file-level MIE group (GroupLength). This length includes
471 both the leading MIE group element and the terminator element
472 itself. The value is an unsigned integer with a byte length given
473 in step 3), and a byte order from step 4). From the current file
474 position (at the end of the data read in step 1), seek backward by
475 this number of bytes to find the start of the MIE group element for
476 this document.
477
478 This algorithm may be repeated again beginning at this point in the
479 file to locate the next-to-last document, etc.
480
481 The table below lists all 5 valid patterns for the last 14 bytes of a
482 file-level MIE group, with all numbers in hex. The comments indicate
483 the length and byte ordering of GroupLength (xx) if available:
484
485 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 7e 00 00 00 - (no GroupLength)
486 ?? ?? ?? ?? 7e 00 00 06 xx xx xx xx 10 04 - 4 bytes, big endian
487 ?? ?? ?? ?? 7e 00 00 06 xx xx xx xx 18 04 - 4 bytes, little endian
488 7e 00 00 0a xx xx xx xx xx xx xx xx 10 08 - 8 bytes, big endian
489 7e 00 00 0a xx xx xx xx xx xx xx xx 18 08 - 8 bytes, little endian
490
491 Trailer Signature
492
493 The MIE format may be used for trailer information appended to other
494 types of files. When this is done, a signature must appear at the end
495 of the main MIE group to uniquely identify the MIE format trailer. To
496 achieve this, a "zmie" trailer signature is written as the last element
497 in the main "0MIE" group. This element has a FormatCode of 0, a
498 TagLength of 4, a DataLength of 0, and a TagName of "zmie". With this
499 signature, the hex byte sequence "7e 00 04 00 7a 6d 69 65" appears
500 immediately before the final group terminator, and the last 22 bytes of
501 the trailer correspond to one of the following 4 patterns (where the
502 trailer length is given by "xx", as above):
503
504 ?? ?? ?? ?? 7e 00 04 00 7a 6d 69 65 7e 00 00 06 xx xx xx xx 10 04
505 ?? ?? ?? ?? 7e 00 04 00 7a 6d 69 65 7e 00 00 06 xx xx xx xx 18 04
506 7e 00 04 00 7a 6d 69 65 7e 00 00 0a xx xx xx xx xx xx xx xx 10 08
507 7e 00 04 00 7a 6d 69 65 7e 00 00 0a xx xx xx xx xx xx xx xx 18 08
508
509 Note that the zero-DataLength terminator may not be used here because
510 the trailer length must be known for seeking backwards from the end of
511 the file.
512
513 Multiple trailers may be appended to the same file using this tech‐
514 nique.
515
516 MIE Data Values
517
518 MIE data values for a given tag are usually not restricted to a spe‐
519 cific FormatCode. Any value may be represented in any appropriate for‐
520 mat, including numbers represented in string (ASCII or UTF) form.
521
522 It is preferred that closely related values with the same format are
523 written to a single tag instead of using multiple tags. This improves
524 localization of like values and decreases MIE element overhead. For
525 instance, instead of separate ImageWidth and ImageHeight tags, a single
526 ImageSize tag is defined.
527
528 Tags which may take on a discrete set of values should have meaningful
529 values if possible. This improves the extensibility of the format and
530 allows a more reasonable interpretation of unrecognized values.
531
532 Numerical Representation
533
534 Integer and floating point numbers may be represented in binary or
535 string form. In string form, integers are a series of digits with an
536 optional leading sign (ie. "[+⎪-]DDDDDD"), and multiple values are sep‐
537 arated by a single space character (ie. "23 128 -32"). Floating point
538 numbers are similar but may also contain a decimal point and/or a
539 signed exponent with a leading 'e' character (ie.
540 "[+⎪-]DD[.DDDDDD][e(+⎪-)EEE]"). The string "inf" is used to represent
541 infinity. One advantage of numerical strings is that they can have an
542 arbitrarily high precision because the possible number of significant
543 digits is virtually unlimited.
544
545 Note that numerical values may have associated units of measurement
546 which are specified in the "TagName" string.
547
548 Date/Time Format
549
550 All MIE dates are strings in the form "YYYY:mm:dd HH:MM:SS.ss+HH:MM".
551 The fractional seconds (".ss") are optional, and if included may con‐
552 tain any number of significant digits (unlike all other fields which
553 are a fixed number of digits and must be padded with leading zeros if
554 necessary). The timezone ("+HH:MM" or "-HH:MM") is recommended but not
555 required. If not given, the local system timezone is assumed.
556
557 MIME Type
558
559 The basic MIME type for a MIE file is "application/x-mie", however the
560 specific MIME type depends on the type of subfile, and is obtained by
561 adding "x-mie-" to the MIME type of the subfile. For example, with a
562 subfile of type "image/jpeg", the MIE file MIME type is
563 "image/x-mie-jpeg". But note that the "x-" is not duplicated if the
564 subfile MIME type already starts with "x-". So a subfile with MIME
565 type "image/x-raw" is contained within a MIE file of type
566 "image/x-mie-raw", not "image/x-mie-x-raw". In the case of multiple
567 documents in a MIE file, the MIME type is taken from the first docu‐
568 ment. Regardless of the subfile type, all MIE-format files should have
569 a filename extension of ".MIE".
570
571 Levels of Support
572
573 Basic MIE reader/writer applications may choose not to provide support
574 for some advanced features of the MIE format. Features which may not
575 be supported by all software are:
576
577 Compression
578 Software not supporting compression must ignore compressed elements
579 and groups, but should be able to process the remaining informa‐
580 tion.
581
582 Large data lengths
583 Some software may limit the maximum size of a MIE group or element.
584 Historically, a limit of 2GB may be imposed by some systems. How‐
585 ever, 8-byte data lengths should be supported by all applications
586 provided the value doesn't exceed the system limit. (ie. For sys‐
587 tems with a 2GB limit, 8-byte data lengths should be supported if
588 the upper 17 bits are all zero.) If a data length above the system
589 limit is encountered, it may be necessary for the application to
590 stop processing if it can not seek to the next element in the file.
591
593 This section gives examples for working with MIE information using
594 ExifTool.
595
596 Encapsulating Information with Data in a MIE File
597
598 The following command encapsulates any file recognized by ExifTool
599 inside a MIE file, and initializes MIE tags from information within the
600 file:
601
602 exiftool -o new.mie -tagsfromfile FILE '-mie:all<all' \
603 '-subfilename<filename' '-subfiletype<filetype' \
604 '-subfilemimetype<mimetype' '-subfiledata<=FILE'
605
606 where "FILE" is the name of the file.
607
608 For unrecognized files, this command may be used:
609
610 exiftool -o new.mie -subfilename=FILE -subfiletype=TYPE \
611 -subfilemimetype=MIME '-subfiledata<=FILE'
612
613 where "TYPE" and "MIME" represent the source file type and MIME type
614 respectively.
615
616 Adding a MIE Trailer to a File
617
618 The MIE format may also be used to store information in a trailer
619 appended to another type of file. Beware that trailers may not be com‐
620 patible with all file formats, but JPEG and TIFF are two formats where
621 additional trailer information doesn't create any problems for normal
622 parsing of the file. Also note that this technique has the disadvan‐
623 tage that trailer information is commonly lost if the file is subse‐
624 quently edited by other software.
625
626 Creating a MIE trailer with ExifTool is a two-step process since
627 ExifTool can't currently be used to add a MIE trailer directly. The
628 example below illustrates the steps for adding a MIE trailer with a
629 small preview image ("small.jpg") to a destination JPEG image
630 ("dst.jpg").
631
632 Step 1) Create a MIE file with a TrailerSignature containing the
633 desired information:
634
635 exiftool -o new.mie -trailersignature=1 -tagsfromfile small.jpg \
636 '-previewimagetype<filetype' '-previewimagesize<imagesize' \
637 '-previewimagename<filename' '-previewimage<=small.jpg'
638
639 Step 2) Append the MIE information to another file. In Unix, this can
640 be done with the 'cat' command:
641
642 cat new.mie >> dst.jpg
643
644 Once added, ExifTool may be used to edit or delete a MIE trailer in a
645 JPEG or TIFF image.
646
647 Multiple MIE Documents in a Single File
648
649 The MIE specification allows multiple MIE documents (or trailers) to
650 exist in a single file. A file like this may be created by simply con‐
651 catenating MIE documents. ExifTool may be used to access information
652 in a specific document by adding a copy number to the MIE group name.
653 For example:
654
655 # write the Author tag in the second MIE document
656 exiftool -mie2:author=phil test.mie
657
658 # delete the first MIE document from a file
659 exiftool -mie1:all= test.mie
660
661 Units of Measurement
662
663 Some MIE tags allow values to be specified in different units of mea‐
664 surement. In the MIE file format these units are combined with the tag
665 name, but when using ExifTool they are specified in brackets after the
666 value:
667
668 exiftool -mie:gpsaltitude='7500(ft)' test.mie
669
670 If no units are provided, the default units are written.
671
672 Localized Text
673
674 Localized text values are accessed by adding a language/country code to
675 the tag name. For example:
676
677 exiftool -comment-en_us='this is a comment' test.mie
678
680 2007-01-21 - Specified LF character (0x0a) for text newline sequence
681 2007-01-19 - Specified ISO 8859-1 character set for extended ASCII codes
682 2007-01-01 - Improved wording of Step 5 for scanning backwards in MIE file
683 2006-12-30 - Added EXAMPLES section and note about UTF BOM
684 2006-12-20 - MIE 1.1: Changed meaning of TypeModifier bit (0x08) for
685 unknown data (FormatType 0x00), and documented byte swapping
686 2006-12-14 - MIE 1.0: Added Data Values and Numerical Representations
687 sections, and added ability to specify units in tag names
688 2006-11-09 - Added Levels of Support section
689 2006-11-03 - Added Trailer Signature
690 2005-11-18 - Original specification created
691
693 Copyright 2003-2007, Phil Harvey (phil at owl.phy.queensu.ca)
694
695 This library is free software; you can redistribute it and/or modify it
696 under the same terms as Perl itself. The MIE format itself is also
697 copyright Phil Harvey, and is covered by the same free-use license.
698
700 <http://owl.phy.queensu.ca/~phil/exiftool/MIE1.1-20070121.pdf>
701
703 "MIE Tags" in Image::ExifTool::TagNames, Image::ExifTool::MIEUnits,
704 Image::ExifTool(3pm)
705
706
707
708perl v5.8.8 2007-09-12 Image::ExifTool::MIE(3)