3 <head> |
3 <head> |
4 <meta charset="utf-8"/> |
4 <meta charset="utf-8"/> |
5 <title>TIFF Metadata Format Specification and Usage Notes</title> |
5 <title>TIFF Metadata Format Specification and Usage Notes</title> |
6 </head> |
6 </head> |
7 <!-- |
7 <!-- |
8 Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
8 Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
9 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
10 |
10 |
11 This code is free software; you can redistribute it and/or modify it |
11 This code is free software; you can redistribute it and/or modify it |
12 under the terms of the GNU General Public License version 2 only, as |
12 under the terms of the GNU General Public License version 2 only, as |
13 published by the Free Software Foundation. Oracle designates this |
13 published by the Free Software Foundation. Oracle designates this |
67 </li> |
67 </li> |
68 </ul> |
68 </ul> |
69 <a href="#StreamMetadata">Native Stream Metadata Format</a><br/> |
69 <a href="#StreamMetadata">Native Stream Metadata Format</a><br/> |
70 <a href="#ImageMetadata">Native Image Metadata Format</a> |
70 <a href="#ImageMetadata">Native Image Metadata Format</a> |
71 |
71 |
72 <h3><a id="Reading">Reading Images</a></h3> |
72 <h2><a id="Reading">Reading Images</a></h2> |
73 |
73 |
74 TIFF images are read by an <a href="../../ImageReader.html">ImageReader</a> |
74 TIFF images are read by an <a href="../../ImageReader.html">ImageReader</a> |
75 which may be controlled by its public interface as well as via a supplied |
75 which may be controlled by its public interface as well as via a supplied |
76 <a href="../../plugins/tiff/TIFFImageReadParam.html">TIFFImageReadParam</a>. |
76 <a href="../../plugins/tiff/TIFFImageReadParam.html">TIFFImageReadParam</a>. |
77 |
77 |
78 <!-- <h4>Supported Image Types</h4> --> |
78 <!-- <h3>Supported Image Types</h3> --> |
79 |
79 |
80 <!-- Table? --> |
80 <!-- Table? --> |
81 |
81 |
82 <h4><a id="ColorConversionRead">Color Conversion</a></h4> |
82 <h3><a id="ColorConversionRead">Color Conversion</a></h3> |
83 |
83 |
84 <p>If the source image data |
84 <p>If the source image data |
85 have photometric type CIE L*a*b* or YCbCr, and the destination color space |
85 have photometric type CIE L*a*b* or YCbCr, and the destination color space |
86 type is RGB, then the source image data will be automatically converted to |
86 type is RGB, then the source image data will be automatically converted to |
87 RGB using an internal color converter.</p> |
87 RGB using an internal color converter.</p> |
88 |
88 |
89 <h4><a id="ColorSpacesRead">Color Spaces</a></h4> |
89 <h3><a id="ColorSpacesRead">Color Spaces</a></h3> |
90 |
90 |
91 The raw color space assigned by default, i.e., in the absence of a |
91 The raw color space assigned by default, i.e., in the absence of a |
92 user-supplied <a href="../../ImageTypeSpecifier.html">ImageTypeSpecifier</a>, |
92 user-supplied <a href="../../ImageTypeSpecifier.html">ImageTypeSpecifier</a>, |
93 will be the first among the following which applies: |
93 will be the first among the following which applies: |
94 |
94 |
152 <p>If the data are known to be in a color space not correctly handled by the |
152 <p>If the data are known to be in a color space not correctly handled by the |
153 foregoing, then an <code>ImageTypeSpecifier</code> should be |
153 foregoing, then an <code>ImageTypeSpecifier</code> should be |
154 supplied to the reader and should be derived from a color space which is correct |
154 supplied to the reader and should be derived from a color space which is correct |
155 for the data in question.</p> |
155 for the data in question.</p> |
156 |
156 |
157 <h4><a id="ICCProfilesRead">ICC Profiles</a></h4> |
157 <h3><a id="ICCProfilesRead">ICC Profiles</a></h3> |
158 |
158 |
159 If an ICC profile is contained in the image metadata |
159 If an ICC profile is contained in the image metadata |
160 (<a href="../../plugins/tiff/BaselineTIFFTagSet.html"> |
160 (<a href="../../plugins/tiff/BaselineTIFFTagSet.html"> |
161 BaselineTIFFTagSet</a>.TAG_ICC_PROFILE, tag number 34675), |
161 BaselineTIFFTagSet</a>.TAG_ICC_PROFILE, tag number 34675), |
162 an attempt will be made to use it to create the color space |
162 an attempt will be made to use it to create the color space |
194 <a href="../../../../java/util/Iterator.html">Iterator</a> returned by |
194 <a href="../../../../java/util/Iterator.html">Iterator</a> returned by |
195 <code>ImageReader.getImageTypes</code>. If the iterator contains |
195 <code>ImageReader.getImageTypes</code>. If the iterator contains |
196 more than one type, the first one will be based on the ICC profile and the |
196 more than one type, the first one will be based on the ICC profile and the |
197 second on the inferred color space.</p> |
197 second on the inferred color space.</p> |
198 |
198 |
199 <h4><a id="MetadataIssuesRead">Metadata Issues</a></h4> |
199 <h3><a id="MetadataIssuesRead">Metadata Issues</a></h3> |
200 |
200 |
201 By default all recognized fields in the TIFF image file directory (IFD) are |
201 By default all recognized fields in the TIFF image file directory (IFD) are |
202 loaded into the native image metadata object. Which fields are loaded may be |
202 loaded into the native image metadata object. Which fields are loaded may be |
203 controlled by setting which TIFF tags the reader is allowed to recognize, |
203 controlled by setting which TIFF tags the reader is allowed to recognize, |
204 whether to read fields with unrecognized tags, and whether to ignore all |
204 whether to read fields with unrecognized tags, and whether to ignore all |
224 object may simplify gaining access to metadata values. An instance of |
224 object may simplify gaining access to metadata values. An instance of |
225 <code>TIFFDirectory</code> may be created from the <code>IIOMetadata</code> |
225 <code>TIFFDirectory</code> may be created from the <code>IIOMetadata</code> |
226 object returned by the TIFF reader using the |
226 object returned by the TIFF reader using the |
227 <code>TIFFDirectory.createFromMetadata</code> method.</p> |
227 <code>TIFFDirectory.createFromMetadata</code> method.</p> |
228 |
228 |
229 <h5><a id="MapNativeStandard"></a> |
229 <h4><a id="MapNativeStandard"></a> |
230 Mapping of TIFF Native Image Metadata to the Standard Metadata Format</h5> |
230 Mapping of TIFF Native Image Metadata to the Standard Metadata Format</h4> |
231 |
231 |
232 The derivation of standard metadata format |
232 The derivation of standard metadata format |
233 <a href="standard_metadata.html">javax_imageio_1.0</a> |
233 <a href="standard_metadata.html">javax_imageio_1.0</a> |
234 elements from <a href="#ImageMetadata">TIFF native image metadata</a> is given |
234 elements from <a href="#ImageMetadata">TIFF native image metadata</a> is given |
235 in the following table. |
235 in the following table. |
347 <td>ExtraSamples: associated alpha => "premultiplied"; |
347 <td>ExtraSamples: associated alpha => "premultiplied"; |
348 unassociated alpha => "nonpremultiplied".</td> |
348 unassociated alpha => "nonpremultiplied".</td> |
349 </tr> |
349 </tr> |
350 </table> |
350 </table> |
351 |
351 |
352 <h4><a id="ExifRead">Reading Exif Images</a></h4> |
352 <h3><a id="ExifRead">Reading Exif Images</a></h3> |
353 |
353 |
354 The TIFF reader may be used to read an uncompressed Exif image or the |
354 The TIFF reader may be used to read an uncompressed Exif image or the |
355 contents of the <code>APP1</code> marker segment of a compressed Exif image. |
355 contents of the <code>APP1</code> marker segment of a compressed Exif image. |
356 |
356 |
357 <h5><a id="ExifReadTIFF">Reading Uncompressed Exif Images</a></h5> |
357 <h4><a id="ExifReadTIFF">Reading Uncompressed Exif Images</a></h4> |
358 |
358 |
359 An uncompressed Exif image is a one- or two-page uncompressed TIFF image |
359 An uncompressed Exif image is a one- or two-page uncompressed TIFF image |
360 with a specific ordering of its IFD and image data content. Each pixel |
360 with a specific ordering of its IFD and image data content. Each pixel |
361 has three 8-bit samples with photometric interpretation RGB or YCbCr. |
361 has three 8-bit samples with photometric interpretation RGB or YCbCr. |
362 The image stream must contain a single primary image and may contain a |
362 The image stream must contain a single primary image and may contain a |
384 |
384 |
385 Note that the Exif thumbnail is treated as a separate page in the TIFF |
385 Note that the Exif thumbnail is treated as a separate page in the TIFF |
386 stream and not as a thumbnail, i.e., |
386 stream and not as a thumbnail, i.e., |
387 <code>tiffReader.hasThumbnails(0)</code> will return <code>false</code>. |
387 <code>tiffReader.hasThumbnails(0)</code> will return <code>false</code>. |
388 |
388 |
389 <h5><a id="ExifReadJPEG">Reading Compressed Exif Images</a></h5> |
389 <h4><a id="ExifReadJPEG">Reading Compressed Exif Images</a></h4> |
390 |
390 |
391 A compressed Exif image is a 3-band ISO/IEC 10918-1 baseline DCT JPEG stream |
391 A compressed Exif image is a 3-band ISO/IEC 10918-1 baseline DCT JPEG stream |
392 with an inserted <code>APP1</code> marker segment. The parameters of the marker |
392 with an inserted <code>APP1</code> marker segment. The parameters of the marker |
393 segment after the length are the 6-byte sequence |
393 segment after the length are the 6-byte sequence |
394 <code>{'E', 'x', 'i', 'f', 0x00, 0x00}</code> |
394 <code>{'E', 'x', 'i', 'f', 0x00, 0x00}</code> |
451 IFDs in the embedded TIFF stream including those corresponding to empty |
451 IFDs in the embedded TIFF stream including those corresponding to empty |
452 images. Calling <code>tiffReader.read(0, readParam)</code> will throw |
452 images. Calling <code>tiffReader.read(0, readParam)</code> will throw |
453 an exception as the primary image in the embedded TIFF stream is always |
453 an exception as the primary image in the embedded TIFF stream is always |
454 empty; the primary image should be obtained using the JPEG reader itself. |
454 empty; the primary image should be obtained using the JPEG reader itself. |
455 |
455 |
456 <h3><a id="Writing">Writing Images</a></h3> |
456 <h2><a id="Writing">Writing Images</a></h2> |
457 |
457 |
458 TIFF images are written by a <a href="../../ImageWriter.html">ImageWriter</a> which may be |
458 TIFF images are written by a <a href="../../ImageWriter.html">ImageWriter</a> which may be |
459 controlled by its public interface as well as via a supplied |
459 controlled by its public interface as well as via a supplied |
460 <a href="../../ImageWriteParam.html">ImageWriteParam</a>. For an <code>ImageWriteParam</code> returned |
460 <a href="../../ImageWriteParam.html">ImageWriteParam</a>. For an <code>ImageWriteParam</code> returned |
461 by the <code>getDefaultWriteParam()</code> method of the TIFF <code>ImageWriter</code>, |
461 by the <code>getDefaultWriteParam()</code> method of the TIFF <code>ImageWriter</code>, |
475 the JPEG minimum coded unit (MCU) in that dimension. If JPEG-in-TIFF |
475 the JPEG minimum coded unit (MCU) in that dimension. If JPEG-in-TIFF |
476 compression is being used and strips are being written, the number of |
476 compression is being used and strips are being written, the number of |
477 rows per strip is rounded to a multiple of 8 times the maximum MCU over |
477 rows per strip is rounded to a multiple of 8 times the maximum MCU over |
478 both dimensions.</p> |
478 both dimensions.</p> |
479 |
479 |
480 <!-- <h4>Supported Image Types</h4> --> |
480 <!-- <h3>Supported Image Types</h3> --> |
481 |
481 |
482 <!-- Table? --> |
482 <!-- Table? --> |
483 |
483 |
484 <h4><a id="Compression">Compression</a></h4> |
484 <h3><a id="Compression">Compression</a></h3> |
485 |
485 |
486 The compression type may be set via the <code>setCompressionType()</code> method of |
486 The compression type may be set via the <code>setCompressionType()</code> method of |
487 the <code>ImageWriteParam</code> after setting the compression mode to |
487 the <code>ImageWriteParam</code> after setting the compression mode to |
488 <code>MODE_EXPLICIT</code>. The set of innately |
488 <code>MODE_EXPLICIT</code>. The set of innately |
489 supported compression types is listed in the following table: |
489 supported compression types is listed in the following table: |
574 rescaled to the range <code>[1, 9]</code> and truncated to an integer |
574 rescaled to the range <code>[1, 9]</code> and truncated to an integer |
575 to derive the Deflate compression level. For JPEG the floating point |
575 to derive the Deflate compression level. For JPEG the floating point |
576 quality value is passed directly to the JPEG writer plug-in which |
576 quality value is passed directly to the JPEG writer plug-in which |
577 interprets it in the usual way.</p> |
577 interprets it in the usual way.</p> |
578 |
578 |
579 <h4><a id="ColorConversionWrite">Color Conversion</a></h4> |
579 <h3><a id="ColorConversionWrite">Color Conversion</a></h3> |
580 |
580 |
581 <p>If the source image data |
581 <p>If the source image data |
582 color space type is RGB, and the destination photometric type is CIE L*a*b* or |
582 color space type is RGB, and the destination photometric type is CIE L*a*b* or |
583 YCbCr, then the source image data will be automatically converted from |
583 YCbCr, then the source image data will be automatically converted from |
584 RGB using an internal color converter.</p> |
584 RGB using an internal color converter.</p> |
585 |
585 |
586 <h4><a id="ICCProfilesWrite">ICC Profiles</a></h4> |
586 <h3><a id="ICCProfilesWrite">ICC Profiles</a></h3> |
587 |
587 |
588 An <code>ICC Profile</code> field will be written if either: |
588 An <code>ICC Profile</code> field will be written if either: |
589 <ul> |
589 <ul> |
590 <li>one is present in the native image metadata |
590 <li>one is present in the native image metadata |
591 <a href="../IIOMetadata.html">IIOMetadata</a> instance supplied to the writer, |
591 <a href="../IIOMetadata.html">IIOMetadata</a> instance supplied to the writer, |
598 <code>ImageWriteParam.setDestinationType(ImageTypeSpecifier)</code> and defaults |
598 <code>ImageWriteParam.setDestinationType(ImageTypeSpecifier)</code> and defaults |
599 to the <code>ImageTypeSpecifier</code> of the image being written. |
599 to the <code>ImageTypeSpecifier</code> of the image being written. |
600 </li> |
600 </li> |
601 </ul> |
601 </ul> |
602 |
602 |
603 <h4><a id="MetadataIssuesWrite">Metadata Issues</a></h4> |
603 <h3><a id="MetadataIssuesWrite">Metadata Issues</a></h3> |
604 |
604 |
605 Some behavior of the writer is affected by or may affect the contents of |
605 Some behavior of the writer is affected by or may affect the contents of |
606 the image metadata which may be supplied by the user. |
606 the image metadata which may be supplied by the user. |
607 |
607 |
608 <p>For bilevel images, the <code>FillOrder</code>, and <code>T4Options</code> |
608 <p>For bilevel images, the <code>FillOrder</code>, and <code>T4Options</code> |
711 <code>IIOMetadata</code> object by invoking |
711 <code>IIOMetadata</code> object by invoking |
712 <code>TIFFDirectory.getAsMetadata</code>. The |
712 <code>TIFFDirectory.getAsMetadata</code>. The |
713 <code>IIOMetadata</code> object so obtained may then be passed to the TIFF |
713 <code>IIOMetadata</code> object so obtained may then be passed to the TIFF |
714 writer.</p> |
714 writer.</p> |
715 |
715 |
716 <h5><a id="MapStandardNative"></a> |
716 <h4><a id="MapStandardNative"></a> |
717 Mapping of the Standard Metadata Format to TIFF Native Image Metadata</h5> |
717 Mapping of the Standard Metadata Format to TIFF Native Image Metadata</h4> |
718 |
718 |
719 The derivation of <a href="#ImageMetadata">TIFF native image metadata</a> |
719 The derivation of <a href="#ImageMetadata">TIFF native image metadata</a> |
720 elements from the standard metadata format |
720 elements from the standard metadata format |
721 <a href="standard_metadata.html">javax_imageio_1.0</a> is |
721 <a href="standard_metadata.html">javax_imageio_1.0</a> is |
722 given in the following table. |
722 given in the following table. |
827 <td></td> |
827 <td></td> |
828 <td></td> |
828 <td></td> |
829 </tr> |
829 </tr> |
830 </table> |
830 </table> |
831 |
831 |
832 <h4><a id="ExifWrite">Writing Exif Images</a></h4> |
832 <h3><a id="ExifWrite">Writing Exif Images</a></h3> |
833 |
833 |
834 The TIFF writer may be used to write an uncompressed Exif image or the |
834 The TIFF writer may be used to write an uncompressed Exif image or the |
835 contents of the <code>APP1</code> marker segment of a compressed Exif image. |
835 contents of the <code>APP1</code> marker segment of a compressed Exif image. |
836 |
836 |
837 <h5><a id="ExifWriteTIFF">Writing Uncompressed Exif Images</a></h5> |
837 <h4><a id="ExifWriteTIFF">Writing Uncompressed Exif Images</a></h4> |
838 |
838 |
839 When writing a sequence of images each image is normally recorded as |
839 When writing a sequence of images each image is normally recorded as |
840 {IFD, IFD Value, Image Data}. The Exif specification requires |
840 {IFD, IFD Value, Image Data}. The Exif specification requires |
841 that an uncompressed Exif image be structured as follows: |
841 that an uncompressed Exif image be structured as follows: |
842 |
842 |
899 new IIOImage(image, null, primaryIFD), |
899 new IIOImage(image, null, primaryIFD), |
900 tiffWriteParam); |
900 tiffWriteParam); |
901 } |
901 } |
902 </code></pre> |
902 </code></pre> |
903 |
903 |
904 <h5><a id="ExifWriteJPEG">Writing Compressed Exif Images</a></h5> |
904 <h4><a id="ExifWriteJPEG">Writing Compressed Exif Images</a></h4> |
905 |
905 |
906 The structure of the embedded TIFF stream in the <code>APP1</code> segment of a |
906 The structure of the embedded TIFF stream in the <code>APP1</code> segment of a |
907 compressed Exif image is identical to the <a href="#ExifStructure"> |
907 compressed Exif image is identical to the <a href="#ExifStructure"> |
908 uncompressed Exif image structure</a> except that there are no primary |
908 uncompressed Exif image structure</a> except that there are no primary |
909 image data, i.e., the primary IFD does not refer to any image data. |
909 image data, i.e., the primary IFD does not refer to any image data. |
1006 The <code>"unknown"</code> node created above would be appended to the |
1006 The <code>"unknown"</code> node created above would be appended to the |
1007 <code>"markerSequence"</code> node of the native JPEG image metadata |
1007 <code>"markerSequence"</code> node of the native JPEG image metadata |
1008 and written to the JPEG stream when the primary image is written using |
1008 and written to the JPEG stream when the primary image is written using |
1009 the JPEG writer. |
1009 the JPEG writer. |
1010 |
1010 |
1011 <h3><a id="StreamMetadata">Stream Metadata</a></h3> |
1011 <h2><a id="StreamMetadata">Stream Metadata</a></h2> |
1012 |
1012 |
1013 The DTD for the TIFF native stream metadata format is as follows: |
1013 The DTD for the TIFF native stream metadata format is as follows: |
1014 |
1014 |
1015 <pre> |
1015 <pre> |
1016 <!DOCTYPE "javax_imageio_tiff_stream_1.0" [ |
1016 <!DOCTYPE "javax_imageio_tiff_stream_1.0" [ |
1023 <!-- One of "BIG_ENDIAN" or "LITTLE_ENDIAN" --> |
1023 <!-- One of "BIG_ENDIAN" or "LITTLE_ENDIAN" --> |
1024 <!-- Data type: String --> |
1024 <!-- Data type: String --> |
1025 ]> |
1025 ]> |
1026 </pre> |
1026 </pre> |
1027 |
1027 |
1028 <h3><a id="ImageMetadata">Image Metadata</a></h3> |
1028 <h2><a id="ImageMetadata">Image Metadata</a></h2> |
1029 |
1029 |
1030 The DTD for the TIFF native image metadata format is as follows: |
1030 The DTD for the TIFF native image metadata format is as follows: |
1031 |
1031 |
1032 <pre> |
1032 <pre> |
1033 <!DOCTYPE "javax_imageio_tiff_image_1.0" [ |
1033 <!DOCTYPE "javax_imageio_tiff_image_1.0" [ |