1 <!doctype html>
   2 <html lang="en">
   3 <head>
   4     <meta charset="utf-8"/>
   5     <title>TIFF Metadata Format Specification and Usage Notes</title>
   6 </head>
   7 <!--
   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.
  10 
  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
  13 published by the Free Software Foundation.  Oracle designates this
  14 particular file as subject to the "Classpath" exception as provided
  15 by Oracle in the LICENSE file that accompanied this code.
  16 
  17 This code is distributed in the hope that it will be useful, but WITHOUT
  18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  19 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  20 version 2 for more details (a copy is included in the LICENSE file that
  21 accompanied this code).
  22 
  23 You should have received a copy of the GNU General Public License version
  24 2 along with this work; if not, write to the Free Software Foundation,
  25 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  26 
  27 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  28 or visit www.oracle.com if you need additional information or have any
  29 questions.
  30 -->
  31 
  32 <body>
  33 <main role="main">
  34 <h1>TIFF Metadata Format Specification and Usage Notes</h1>
  35 
  36 <a href="#Reading">Reading Images</a>
  37 <ul>
  38 <li><a href="#ColorConversionRead">Color Conversion</a></li>
  39 <li><a href="#ColorSpacesRead">Color Spaces</a></li>
  40 <li><a href="#ICCProfilesRead">ICC Profiles</a></li>
  41 <li><a href="#MetadataIssuesRead">Metadata Issues</a>
  42 <ul>
  43 <li><a href="#MapNativeStandard">Native to Standard Metadata Mapping</a></li>
  44 </ul>
  45 </li>
  46 <li><a href="#ExifRead">Reading Exif Images</a>
  47 <ul>
  48 <li><a href="#ExifReadTIFF">Reading Uncompressed Exif Images</a></li>
  49 <li><a href="#ExifReadJPEG">Reading Compressed Exif Images</a></li>
  50 </ul>
  51 </li>
  52 </ul>
  53 <a href="#Writing">Writing Images</a><br/>
  54 <ul>
  55 <li><a href="#Compression">Compression</a></li>
  56 <li><a href="#ColorConversionWrite">Color Conversion</a></li>
  57 <li><a href="#ICCProfilesWrite">ICC Profiles</a></li>
  58 <li><a href="#MetadataIssuesWrite">Metadata Issues</a>
  59 <ul>
  60 <li><a href="#MapStandardNative">Standard to Native Metadata Mapping</a></li>
  61 </ul>
  62 <li><a href="#ExifWrite">Writing Exif Images</a>
  63 <ul>
  64 <li><a href="#ExifWriteTIFF">Writing Uncompressed Exif Images</a></li>
  65 <li><a href="#ExifWriteJPEG">Writing Compressed Exif Images</a></li>
  66 </ul>
  67 </li>
  68 </ul>
  69 <a href="#StreamMetadata">Native Stream Metadata Format</a><br/>
  70 <a href="#ImageMetadata">Native Image Metadata Format</a>
  71 
  72 <h2><a id="Reading">Reading Images</a></h2>
  73 
  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
  76 <a href="../../plugins/tiff/TIFFImageReadParam.html">TIFFImageReadParam</a>.
  77 
  78 <!-- <h3>Supported Image Types</h3> -->
  79 
  80 <!-- Table? -->
  81 
  82 <h3><a id="ColorConversionRead">Color Conversion</a></h3>
  83 
  84 <p>If the source image data
  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
  87 RGB using an internal color converter.</p>
  88 
  89 <h3><a id="ColorSpacesRead">Color Spaces</a></h3>
  90 
  91 The raw color space assigned by default, i.e., in the absence of a
  92 user-supplied <a href="../../ImageTypeSpecifier.html">ImageTypeSpecifier</a>,
  93 will be the first among the following which applies:
  94 
  95 <ul>
  96 <li>A color space created from the <a href="#ICCProfilesRead">ICC Profile</a>
  97 metadata field if it is present and compatible with the image data
  98 layout.</li>
  99 <li><a id="nonICCProfile"></a>sRGB if the image is monochrome/bilevel
 100 (a two-level color map is created internally).</li>
 101 <li>sRGB if the image is palette-color.</li>
 102 <li>Linear RGB if the image has three samples per pixel, has photometric type
 103 CIE L*a*b*, or has photometric type YCbCr and is <i>not</i>
 104 JPEG-compressed.</li>
 105 <li>A <a href="#DefaultCMYK">default CMYK color space</a> if the image has
 106 photometric type CMYK and four samples per pixel.</li>
 107 <li>Grayscale if the image has one or two samples per pixel and uniformly
 108 1, 2, 4, 8, 16, or 32 bits per sample or is floating point.</li>
 109 <li>sRGB if the image has three or four samples per pixel and uniformly
 110 1, 2, 4, 8, 16, or 32 bits per sample or is floating point.</li>
 111 <li>A fabricated, <a href="#GenericCS">generic color space</a> if the image
 112 has more than four samples per pixel and the number of bits per sample for
 113 all bands is the same and is a multiple of 8.</li>
 114 <li>Grayscale if the image has one or two samples per pixel regardless of
 115 the number of bits per sample.</li>
 116 <li>sRGB if the image has three or four samples per pixel regardless of
 117 the number of bits per sample.</li>
 118 <li>A fabricated, <a href="#GenericCS">generic color space</a> if the image
 119 has more than four samples per pixel regardless of the number of bits per
 120 sample.</li>
 121 </ul>
 122 
 123 <p><a id="DefaultCMYK"></a>The normalized color coordinate transformations
 124 used for the default CMYK color space are defined as follows:
 125 
 126 <ul>
 127 <li>CMYK to linear RGB
 128 <pre>
 129 R = (1 - K)*(1 - C)
 130 G = (1 - K)*(1 - M)
 131 B = (1 - K)*(1 - Y)
 132 </pre>
 133 </li>
 134 <li>Linear RGB to CMYK
 135 <pre>
 136 K = min{1 - R, 1 - G, 1 - B}
 137 if(K != 1) {
 138     C = (1 - R - K)/(1 - K)
 139     M = (1 - G - K)/(1 - K)
 140     Y = (1 - B - K)/(1 - K)
 141 } else {
 142     C = M = Y = 0
 143 }
 144 </pre>
 145 </li>
 146 </ul>
 147 
 148 <p><a id="GenericCS"></a>The generic color space used when no other color space
 149 can be inferred is provided merely to enable the data to be loaded. It is not
 150 intended to provide accurate conversions of any kind.</p>
 151 
 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
 154 supplied to the reader and should be derived from a color space which is correct
 155 for the data in question.</p>
 156 
 157 <h3><a id="ICCProfilesRead">ICC Profiles</a></h3>
 158 
 159 If an ICC profile is contained in the image metadata
 160 (<a href="../../plugins/tiff/BaselineTIFFTagSet.html">
 161 BaselineTIFFTagSet</a>.TAG_ICC_PROFILE, tag number 34675),
 162 an attempt will be made to use it to create the color space
 163 of the loaded image. It will be used if the data layout is of component type
 164 and the number of samples per pixel equals or is one greater than the number
 165 of components described by the ICC profile. If the ICC profile is not used
 166 then the color space will be inferred in one of the subsequent steps described
 167 <a href="#nonICCProfile">above</a>.
 168 
 169 <p>If for some reason the embedded ICC profile is not used automatically, then
 170 it may be used manually by following this procedure:
 171 
 172 <ol>
 173 <li>Obtain the image metadata from
 174 <code>ImageReader.getImageMetadata</code></li>
 175 <li>Extract the ICC profile field and its value.</li>
 176 <li>Create an <a href="../../../../java/awt/color/ICC_ColorSpace.html">
 177 ICC_ColorSpace</a> from an
 178 <a href="../../../../java/awt/color/ICC_Profile.html">
 179 ICC_Profile</a> created from the ICC profile field data
 180 using <code>ICC_Profile.getInstance(byte[])</code>.</li>
 181 <li>Create an <code>ImageTypeSpecifier</code> from the new color
 182 space using one of its factory methods which accepts an
 183 <code>ICC_ColorSpace</code>.
 184 <li>Create a compatible <a href="../../ImageReadParam.html">ImageReadParam</a>
 185 and set the <code>ImageTypeSpecifier</code> using
 186 <code>ImageReadParam.setDestinationType</code>.</li>
 187 <li>Pass the parameter object to the appropriate <code>read</code> method.</li>
 188 </ol>
 189 
 190 <p>If the inferred color space not based on the ICC Profile field is compatible
 191 with the ICC profile-based color space, then a second
 192 <code>ImageTypeSpecifier</code> derived from this inferred color
 193 space will be included in the
 194 <a href="../../../../java/util/Iterator.html">Iterator</a> returned by
 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
 197 second on the inferred color space.</p>
 198 
 199 <h3><a id="MetadataIssuesRead">Metadata Issues</a></h3>
 200 
 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
 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
 205 metadata. The reader is informed to disregard all metadata as usual via the
 206 <code>ignoreMetadata</code> parameter of
 207 <code>ImageReader.setInput(Object,boolean,boolean)</code>. It is
 208 informed of which <a href="../../plugins/tiff/TIFFTag.html">TIFFTag</a>s to
 209 recognize or not to recognize via
 210 <code>TIFFImageReadParam.addAllowedTagSet(TIFFTagSet)</code> and
 211 <code>TIFFImageReadParam.removeAllowedTagSet(TIFFTagSet)</code>.
 212 If <code>ignoreMetadata</code> is <code>true</code>, then only metadata
 213 essential to reading the image will be loaded into the native image metadata
 214 object. If <code>ignoreMetadata</code> is <code>false</code>, then the reader
 215 will by default load into the native image metadata object only those fields
 216 which are either essential to reading the image or have a <code>TIFFTag</code>
 217 contained in the one of the allowed <code>TIFFTagSet</code>s. Reading of
 218 fields with tags not in the allowed <code>TIFFTagSet</code>s may be forced
 219 by passing in a <code>TIFFImageReadParam</code> on which
 220 <code>TIFFImageReadParam.setReadUnknownTags(boolean)</code> has been
 221 invoked with parameter <code>true</code>.
 222 
 223 <p>Use of a <a href="../../plugins/tiff/TIFFDirectory.html">TIFFDirectory</a>
 224 object may simplify gaining access to metadata values. An instance of
 225 <code>TIFFDirectory</code> may be created from the <code>IIOMetadata</code>
 226 object returned by the TIFF reader using the
 227 <code>TIFFDirectory.createFromMetadata</code> method.</p>
 228 
 229 <h4><a id="MapNativeStandard"></a>
 230 Mapping of TIFF Native Image Metadata to the Standard Metadata Format</h4>
 231 
 232 The derivation of standard metadata format
 233 <a href="standard_metadata.html">javax_imageio_1.0</a>
 234 elements from <a href="#ImageMetadata">TIFF native image metadata</a> is given
 235 in the following table.
 236 
 237 <table border="1">
 238 <tr>
 239 <th>Standard Metadata Element</th>
 240 <th>Derivation from TIFF Fields</th>
 241 </tr>
 242 <tr>
 243 <td>/Chroma/ColorSpaceType@name</td>
 244 <td>PhotometricInterpretation: WhiteIsZero, BlackIsZero, TransparencyMask =
 245 "GRAY"; RGB, PaletteColor =&gt; "RGB"; CMYK =&gt; "CMYK";
 246 YCbCr =&gt; "YCbCr";
 247 CIELab, ICCLab =&gt; "Lab".</td>
 248 </tr>
 249 <tr>
 250 <td>/Chroma/NumChannels@value</td>
 251 <td>SamplesPerPixel</td>
 252 </tr>
 253 <tr>
 254 <td>/Chroma/BlackIsZero@value</td>
 255 <td>"TRUE" &lt;=&gt; PhotometricInterpretation =&gt; WhiteIsZero</td>
 256 </tr>
 257 <tr>
 258 <td>/Chroma/Palette</td>
 259 <td>ColorMap</td>
 260 </tr>
 261 <tr>
 262 <td>/Compression/CompressionTypeName@value</td>
 263 <td>Compression: Uncompressed =&gt; "none"; CCITT 1D =&gt; "CCITT
 264 RLE";
 265 Group 3 Fax =&gt; "CCITT T.4"; Group 4 Fax =&gt; "CCITT T.6";
 266 LZW =&gt; "LZW";
 267 JPEG =&gt; "Old JPEG"; New JPEG =&gt; "JPEG"; Zlib =&gt;&gt; "ZLib"; PackBits =&gt;
 268 "PackBits";
 269 Deflate =&gt; "Deflate"; Exif JPEG =&gt; "JPEG".</td>
 270 </tr>
 271 <tr>
 272 <td>/Compression/Lossless@value</td>
 273 <td>Compression: JPEG or New JPEG =&gt; "FALSE"; otherwise "TRUE".</td>
 274 </tr>
 275 <tr>
 276 <td>/Data/PlanarConfiguration@value</td>
 277 <td>Chunky =&gt; "PixelInterleaved"; Planar =&gt; "PlaneInterleaved".</td>
 278 </tr>
 279 <tr>
 280 <td>/Data/SampleFormat@value</td>
 281 <td>PhotometricInterpretation PaletteColor =&gt; "Index";
 282 SampleFormat unsigned integer data =&gt; "UnsignedIntegral";
 283 SampleFormat two's complement signed integer data =&gt; "SignedIntegral";
 284 SampleFormat IEEE floating point data =&gt; "Real";
 285 otherwise element not emitted.
 286 </td>
 287 </tr>
 288 <tr>
 289 <td>/Data/BitsPerSample@value</td>
 290 <td>BitsPerSample as a space-separated list.</td>
 291 </tr>
 292 <tr>
 293 <td>/Data/SampleMSB@value</td>
 294 <td>FillOrder: left-to-right =&gt; space-separated list of BitsPerSample-1;
 295 right-to-left =&gt; space-separated list of 0s.</td>
 296 </tr>
 297 <tr>
 298 <td>/Dimension/PixelAspectRatio@value</td>
 299 <td>(1/XResolution)/(1/YResolution)</td>
 300 </tr>
 301 <tr>
 302 <td>/Dimension/ImageOrientation@value</td>
 303 <td>Orientation</td>
 304 </tr>
 305 <tr>
 306 <td>/Dimension/HorizontalPixelSize@value</td>
 307 <td>1/XResolution in millimeters if ResolutionUnit is not None.</td>
 308 </tr>
 309 <tr>
 310 <td>/Dimension/VerticalPixelSize@value</td>
 311 <td>1/YResolution in millimeters if ResolutionUnit is not None.</td>
 312 </tr>
 313 <tr>
 314 <td>/Dimension/HorizontalPosition@value</td>
 315 <td>XPosition in millimeters if ResolutionUnit is not None.</td>
 316 </tr>
 317 <tr>
 318 <td>/Dimension/VerticalPosition@value</td>
 319 <td>YPosition in millimeters if ResolutionUnit is not None.</td>
 320 </tr>
 321 <tr>
 322 <td>/Document/FormatVersion@value</td>
 323 <td>6.0</td>
 324 </tr>
 325 <tr>
 326 <td>/Document/SubimageInterpretation@value</td>
 327 <td>NewSubFileType: transparency =&gt; "TransparencyMask";
 328 reduced-resolution =&gt; "ReducedResolution";
 329 single page =&gt; "SinglePage".</td>
 330 </tr>
 331 <tr>
 332 <td>/Document/ImageCreationTime@value</td>
 333 <td>DateTime</td>
 334 </tr>
 335 <tr>
 336 <td>/Text/TextEntry</td>
 337 <td>DocumentName, ImageDescription, Make, Model, PageName, Software,
 338 Artist, HostComputer, InkNames, Copyright:
 339 /Text/TextEntry@keyword = field name,
 340 /Text/TextEntry@value = field value.<br>
 341 Example: TIFF Software field =&gt; /Text/TextEntry@keyword = "Software",
 342 /Text/TextEntry@value = Name and version number of the software package(s)
 343 used to create the image.</td>
 344 </tr>
 345 <tr>
 346 <td>/Transparency/Alpha@value</td>
 347 <td>ExtraSamples: associated alpha =&gt; "premultiplied";
 348 unassociated alpha =&gt; "nonpremultiplied".</td>
 349 </tr>
 350 </table>
 351 
 352 <h3><a id="ExifRead">Reading Exif Images</a></h3>
 353 
 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.
 356 
 357 <h4><a id="ExifReadTIFF">Reading Uncompressed Exif Images</a></h4>
 358 
 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
 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
 363 single thumbnail which if present must also be uncompressed. The usual
 364 <code>ImageReader</code> methods may be used to read the image
 365 data and metadata:
 366 
 367 <pre><code>
 368     ImageInputStream input;
 369     ImageReader tiffReader;
 370     ImageReadParam tiffReadParam;
 371 
 372     tiffReader.setInput(input);
 373 
 374     // Read primary image and IFD.
 375     BufferedImage image = tiffReader.read(0, tiffReadParam);
 376     IIOMetadata primaryIFD = tiffReader.getImageMetadata(0);
 377 
 378     // Read thumbnail if present.
 379     BufferedImage thumbnail = null;
 380     if (tiffReader.getNumImages(true) > 1) {
 381         thumbnail = tiffReader.read(1, tiffReadParam);
 382     }
 383 </code></pre>
 384 
 385 Note that the Exif thumbnail is treated as a separate page in the TIFF
 386 stream and not as a thumbnail, i.e.,
 387 <code>tiffReader.hasThumbnails(0)</code> will return <code>false</code>.
 388 
 389 <h4><a id="ExifReadJPEG">Reading Compressed Exif Images</a></h4>
 390 
 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
 393 segment after the length are the 6-byte sequence
 394 <code>{'E',&nbsp;'x',&nbsp;'i',&nbsp;'f',&nbsp;0x00,&nbsp;0x00}</code>
 395 followed by a complete TIFF stream. The embedded TIFF stream contains a primary
 396 IFD describing the JPEG image optionally followed by a thumbnail IFD and
 397 compressed or uncompressed thumbnail image data. Note that the embedded TIFF
 398 stream does not contain any image data associated with the primary IFD
 399 nor any descriptive fields which duplicate information found in the JPEG
 400 stream itself.
 401 
 402 <p>The parameter content of the <code>APP1</code> marker segment may be obtained
 403 from the user object of the associated <code>Node</code> in a
 404 <code>javax_imageio_jpeg_image_1.0</code> native image metadata tree extracted
 405 from the image metadata object returned by the JPEG reader. This APP1 Exif
 406 node will be a child of the node named "markerSequence" and will
 407 have name <code>unknown</code> and an attribute named <code>MarkerTag</code> with
 408 integral value <code>0xE1</code> (<code>String</code> value
 409 <code>"225"</code>). The user object of this node will be a byte array
 410 which starts with the six bytes <code>{'E', 'x', 'i', 'f', '0', '0'}</code>.
 411 The primary IFD and the thumbnail IFD and image may be
 412 read from the user object by the usual <code>ImageReader</code>
 413 methods:
 414 
 415 <pre><code>
 416     ImageReader jpegReader;
 417     ImageReader tiffReader;
 418 
 419     // Obtain the APP1 Exif marker data from the JPEG image metadata.
 420     IIOMetadata jpegImageMetadata = jpegReader.getImageMetadata(0);
 421     String nativeFormat = jpegImageMetadata.getNativeMetadataFormatName();
 422     Node jpegImageMetadataTree = jpegImageMetadata.getAsTree(nativeFormat);
 423 
 424     // getExifMarkerData() returns the byte array which is the user object
 425     // of the APP1 Exif marker node.
 426     byte[] app1Params = getExifMarkerData(jpegImageMetadataTree);
 427     if (app1Params == null) {
 428         throw new IIOException("APP1 Exif marker not found.");
 429     }
 430 
 431     // Set up input, skipping Exif ID 6-byte sequence.
 432     MemoryCacheImageInputStream app1ExifInput
 433         = new MemoryCacheImageInputStream
 434             (new ByteArrayInputStream(app1Params, 6, app1Params.length - 6));
 435     tiffReader.setInput(app1ExifInput);
 436 
 437     // Read primary IFD.
 438     IIOMetadata primaryIFD = tiffReader.getImageMetadata(0);
 439 
 440     // Read thumbnail if present.
 441     BufferedImage thumbnail = null;
 442     if (tiffReader.getNumImages(true) > 1) {
 443         thumbnail = tiffReader.read(1, tiffReadParam);
 444     }
 445 
 446     // Read the primary image.
 447     BufferedImage image = jpegReader.read(0);
 448 </code></pre>
 449 
 450 Note that <code>tiffReader.getNumImages(true)</code> returns the number of
 451 IFDs in the embedded TIFF stream including those corresponding to empty
 452 images. Calling <code>tiffReader.read(0,&nbsp;readParam)</code> will throw
 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.
 455 
 456 <h2><a id="Writing">Writing Images</a></h2>
 457 
 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
 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>,
 462 the <code>canWriteTiles()</code> and <code>canWriteCompressed()</code> methods
 463 will return <code>true</code>; the <code>canOffsetTiles()</code> and
 464 <code>canWriteProgressive()</code> methods will return <code>false</code>.
 465 
 466 The TIFF writer supports many optional capabilities including writing tiled
 467 images, inserting images, writing or inserting empty images, and replacing image
 468 data. Pixels may be replaced in either empty or non-empty images but if and
 469 only if the data are not compressed.
 470 
 471 <p> If tiles are being written, then each of their dimensions will be
 472 rounded to the nearest multiple of 16 per the TIFF specification. If
 473 JPEG-in-TIFF compression is being used, and tiles are being written
 474 each tile dimension will be rounded to the nearest multiple of 8 times
 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
 477 rows per strip is rounded to a multiple of 8 times the maximum MCU over
 478 both dimensions.</p>
 479 
 480  <!-- <h3>Supported Image Types</h3> -->
 481 
 482 <!-- Table? -->
 483 
 484 <h3><a id="Compression">Compression</a></h3>
 485 
 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
 488 <code>MODE_EXPLICIT</code>. The set of innately
 489 supported compression types is listed in the following table:
 490 
 491 <table border=1>
 492 <caption><b>Supported Compression Types</b></caption>
 493 <tr><th>Compression Type</th> <th>Description</th> <th>Reference</th></tr>
 494 <tr>
 495 <td>CCITT RLE</td>
 496 <td>Modified Huffman compression</td>
 497 <td>TIFF 6.0 Specification, Section 10</td>
 498 </tr>
 499 <tr>
 500 <td>CCITT T.4</td>
 501 <td>CCITT T.4 bilevel encoding/Group 3 facsimile compression</td>
 502 <td>TIFF 6.0 Specification, Section 11</td>
 503 </tr>
 504 <tr>
 505 <td>CCITT T.6</td>
 506 <td>CCITT T.6 bilevel encoding/Group 4 facsimile compression</td>
 507 <td>TIFF 6.0 Specification, Section 11</td></tr>
 508 <tr>
 509 <td>LZW</td>
 510 <td>LZW compression</td>
 511 <td>TIFF 6.0 Specification, Section 13</td></tr>
 512 <tr>
 513 <td>JPEG</td>
 514 <td>"New" JPEG-in-TIFF compression</td>
 515 <td><a href="ftp://ftp.sgi.com/graphics/tiff/TTN2.draft.txt">TIFF
 516 Technical Note #2</a></td>
 517 </tr>
 518 <tr>
 519 <td>ZLib</td>
 520 <td>"Deflate/Inflate" compression (see note following this table)</td>
 521 </tr>
 522 <tr>
 523 <td>PackBits</td>
 524 <td>Byte-oriented, run length compression</td>
 525 <td>TIFF 6.0 Specification, Section 9</td>
 526 </tr>
 527 <tr>
 528 <td>Deflate</td>
 529 <td>"Zip-in-TIFF" compression (see note following this table)</td>
 530 <td><a href="https://tools.ietf.org/html/rfc1950">
 531 ZLIB Compressed Data Format Specification</a>,
 532 <a href="https://tools.ietf.org/html/rfc1951">
 533 DEFLATE Compressed Data Format Specification</a></td>
 534 </tr>
 535 <tr>
 536 <td>Exif JPEG</td>
 537 <td>Exif-specific JPEG compression (see note following this table)</td>
 538 <td><a href="http://www.exif.org/Exif2-2.PDF">Exif 2.2 Specification</a>
 539 (PDF), section 4.5.5, "Basic Structure of Thumbnail Data"</td>
 540 </table>
 541 
 542 <p>
 543 Old-style JPEG compression as described in section 22 of the TIFF 6.0
 544 Specification is <i>not</i> supported.
 545 </p>
 546 
 547 <p> The CCITT compression types are applicable to bilevel (1-bit)
 548 images only.  The JPEG compression type is applicable to byte
 549 grayscale (1-band) and RGB (3-band) images only.</p>
 550 
 551 <p>
 552 ZLib and Deflate compression are identical except for the value of the
 553 TIFF Compression field: for ZLib the Compression field has value 8
 554 whereas for Deflate it has value 32946 (0x80b2). In both cases each
 555 image segment (strip or tile) is written as a single complete zlib data
 556 stream.
 557 </p>
 558 
 559 <p>
 560 "Exif JPEG" is a compression type used when writing the contents of an
 561 APP1 Exif marker segment for inclusion in a JPEG native image metadata
 562 tree. The contents appended to the output when this compression type is
 563 used are a function of whether an empty or non-empty image is written.
 564 If the image is empty, then a TIFF IFD adhering to the specification of
 565 a compressed Exif primary IFD is appended. If the image is non-empty,
 566 then a complete IFD and image adhering to the specification of a
 567 compressed Exif thumbnail IFD and image are appended. Note that the
 568 data of the empty image may <i>not</i> later be appended using the pixel
 569 replacement capability of the TIFF writer.
 570 </p>
 571 
 572 <p> If ZLib/Deflate or JPEG compression is used, the compression quality
 573 may be set. For ZLib/Deflate the supplied floating point quality value is
 574 rescaled to the range <code>[1,&nbsp;9]</code> and truncated to an integer
 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
 577 interprets it in the usual way.</p>
 578 
 579 <h3><a id="ColorConversionWrite">Color Conversion</a></h3>
 580 
 581 <p>If the source image data
 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
 584 RGB using an internal color converter.</p>
 585 
 586 <h3><a id="ICCProfilesWrite">ICC Profiles</a></h3>
 587 
 588 An <code>ICC Profile</code> field will be written if either:
 589 <ul>
 590 <li>one is present in the native image metadata
 591 <a href="../IIOMetadata.html">IIOMetadata</a> instance supplied to the writer,
 592 or</li>
 593 <li>the <a href="../../../../java/awt/color/ColorSpace.html">ColorSpace</a>
 594 of the destination <code>ImageTypeSpecifier</code> is an instance of
 595 <code>ICC_ColorSpace</code> which is not one of the standard
 596 color spaces defined by the <code>CS_*</code> constants in the
 597 <code>ColorSpace</code> class. The destination type is set via
 598 <code>ImageWriteParam.setDestinationType(ImageTypeSpecifier)</code> and defaults
 599 to the <code>ImageTypeSpecifier</code> of the image being written.
 600 </li>
 601 </ul>
 602 
 603 <h3><a id="MetadataIssuesWrite">Metadata Issues</a></h3>
 604 
 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.
 607 
 608 <p>For bilevel images, the <code>FillOrder</code>, and <code>T4Options</code>
 609 fields affect the output data. The data will be filled right-to-left if
 610 <code>FillOrder</code> is present with a value of 2
 611 (<code>BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT</code>)
 612 and will be filled left-to-right otherwise. The value of <code>T4Options</code>
 613 specifies whether the data should be 1D- or 2D-encoded and whether EOL
 614 padding should be used.</p>
 615 
 616 <p>For all images the value of the <code>RowsPerStrip</code> field is used
 617 to the set the number of rows per strip if the image is not tiled. The
 618 default number of rows per strip is either 8 or the number of rows which
 619 would fill no more than 8 kilobytes, whichever is larger.</p>
 620 
 621 <p>For all images the tile dimensions may be set using the <code>TileWidth</code>
 622 and <code>TileLength</code> field values if the tiling mode is
 623 <code>ImageWriteParam.MODE_COPY_FROM_METADATA</code>. If this mode
 624 is set but the fields are not, their respective default values are the image
 625 width and height.</p>
 626 
 627 <p>When using JPEG-in-TIFF compression, a <code>JPEGTables</code> field will be
 628 written to the IFD and abbreviated JPEG streams to each strip or tile if and
 629 only if a <code>JPEGTables</code> field is contained in the metadata object
 630 provided to the writer. If the contents of the <code>JPEGTables</code> field is
 631 a valid tables-only JPEG stream, then it will be used; otherwise the contents
 632 of the field will be replaced with default visually lossless tables. If no
 633 such <code>JPEGTables</code> field is present in the metadata, then no
 634 <code>JPEGTables</code> field will be written to the output and each strip or
 635 tile will be written as a separate, self-contained JPEG stream.</p>
 636 
 637 <p>When using Deflate/ZLib or LZW compression, if the image has 8 bits per
 638 sample, a horizontal differencing predictor will be used if the
 639 <code>Predictor</code> field is present with a value of 2
 640 (<code>BaselineTIFFTagSet.PREDICTOR_HORIZONTAL_DIFFERENCING</code>).
 641 If prediction is so requested but the image does not have
 642 8 bits per sample the field will be reset to have the value 1
 643 (<code>BaselineTIFFTagSet.PREDICTOR_NONE</code>).
 644 </p>
 645 
 646 <p>Some fields may be added or modified:
 647 
 648 <ul>
 649 <li><code>PhotometricInterpretation</code> if not present.</li>
 650 <li><code>PlanarConfiguration</code> if this field is present with value
 651 <code>Planar</code> is is reset to <code>Chunky</code>.</li>
 652 <li><code>Compression</code> always.</li>
 653 <li><code>BitsPerSample</code> if the image is not bilevel.</li>
 654 <li><code>SamplesPerPixel</code> always.</li>
 655 <li><code>ExtraSamples</code> if an alpha channel is present.</li>
 656 <li><code>SampleFormat</code> if not present and the data are 16- or 32-bit
 657 integers or floating point.</li>
 658 <li><code>ColorMap</code> if the <code>PhotometricInterpretation</code> is
 659 <code>RGBPalette</code>.</li>
 660 <li><code>ImageWidth</code> and <code>ImageLength</code> always.</li>
 661 <li><code>TileWidth</code>, <code>TileLength</code>, <code>TileOffsets</code>, and
 662 <code>TileByteCounts</code> if a tiled image is being written.</li>
 663 <li><code>RowsPerStrip</code>, <code>StripOffsets</code>, and <code>StripByteCounts</code>
 664 if a tiled image is <i>not</i> being written.</li>
 665 <li><code>XResolution</code>, <code>YResolution</code>, and <code>ResolutionUnit</code>
 666 if none of these is present.</li>
 667 <li><code>YCbCrSubsampling</code> and <code>YCbCrPositioning</code> if the
 668 photometric interpretation is YCbCr and the compression type is not JPEG
 669 (only [1,&nbsp;1] subsampling and cosited positioning are supported for
 670 non-JPEG YCbCr output).</li>
 671 <li><code>YCbCrSubsampling</code>, <code>YCbCrPositioning</code>, and
 672 <code>ReferenceBlackWhite</code>: if the compression type is JPEG and the color
 673 space is RGB these will be reset to [2,&nbsp;2] centered subsampling with no
 674 headroom/footroom (0:255,128:255,128:255).</li>
 675 </ul>
 676 
 677 <p>Some fields may be removed:
 678 
 679 <ul>
 680 <li><code>BitsPerSample</code> if the image is bilevel.</li>
 681 <li><code>ExtraSamples</code> if the image does not have an alpha channel.</li>
 682 <li><code>ColorMap</code> if the photometric interpretation is not
 683 <code>RGBPalette</code>.</li>
 684 <li><code>TileWidth</code>, <code>TileLength</code>, <code>TileOffsets</code>, and
 685 <code>TileByteCounts</code> if tiling <i>is not</i> being used.</li>
 686 <li><code>RowsPerStrip</code>, <code>StripOffsets</code>, and <code>StripByteCounts</code>
 687 if tiling <i>is</i> being used.</li>
 688 <li><code>YCbCrSubsampling</code>, <code>YCbCrPositioning</code>, and
 689 <code>ReferenceBlackWhite</code> if the compression type is JPEG and the
 690 color space is grayscale.</li>
 691 <li><code>JPEGProc</code>, <code>JPEGInterchangeFormat</code>,
 692 <code>JPEGInterchangeFormatLength</code>, <code>JPEGRestartInterval</code>,
 693 <code>JPEGLosslessPredictors</code>, <code>JPEGPointTransforms</code>,
 694 <code>JPEGQTables</code>, <code>JPEGDCTables</code>, and
 695 <code>JPEGACTables</code> if the compression type is JPEG.</li>
 696 </ul>
 697 
 698 <p>Other fields present in the supplied metadata are uninterpreted and will
 699 be written as supplied.</p>
 700 
 701 <p>If an Exif image is being written, the set of fields present and their
 702 values will be modified such that the result is in accord with the Exif 2.2
 703 specification.</p>
 704 
 705 <p>Setting up the image metadata to write to a TIFF stream may be simplified
 706 by using the <code>TIFFDirectory</code> class
 707 which represents a TIFF IFD. A field in a TIFF IFD is represented by an
 708 instance of <a href="../../plugins/tiff/TIFFField.html">TIFFField</a>. For each
 709 field to be written a <code>TIFFField</code> may be added to the
 710 <code>TIFFDirectory</code> and the latter converted to an
 711 <code>IIOMetadata</code> object by invoking
 712 <code>TIFFDirectory.getAsMetadata</code>. The
 713 <code>IIOMetadata</code> object so obtained may then be passed to the TIFF
 714 writer.</p>
 715 
 716 <h4><a id="MapStandardNative"></a>
 717 Mapping of the Standard Metadata Format to TIFF Native Image Metadata</h4>
 718 
 719 The derivation of <a href="#ImageMetadata">TIFF native image metadata</a>
 720 elements from the standard metadata format
 721 <a href="standard_metadata.html">javax_imageio_1.0</a> is
 722 given in the following table.
 723 
 724 <table border="1">
 725 <tr>
 726 <th>TIFF Field</th>
 727 <th>Derivation from Standard Metadata Elements</th>
 728 </tr>
 729 <tr>
 730 <td>
 731 PhotometricInterpretation
 732 </td>
 733 <td>/Chroma/ColorSpaceType@name: "GRAY" and /Chroma/BlackIsZero@value = "FALSE"
 734 =&gt; WhiteIsZero; "GRAY" and /Document/SubimageInterpretation@value =
 735 "TransparencyMask" =&gt; TransparencyMask; "RGB" and /Chroma/Palette present =&gt;
 736 PaletteColor; "GRAY" =&gt; BlackIsZero; "RGB" =&gt; RGB; "YCbCr" =&gt; YCbCr;
 737 "CMYK" =&gt; CMYK; "Lab" =&gt; CIELab.</td>
 738 </tr>
 739 <tr>
 740 <td>SamplesPerPixel</td>
 741 <td>/Chroma/NumChannels@value</td>
 742 </tr>
 743 <tr>
 744 <td>ColorMap</td>
 745 <td>/Chroma/Palette</td>
 746 </tr>
 747 <tr>
 748 <td>Compression</td>
 749 <td>/Compression/CompressionTypeName@value: "none" =&gt; Uncompressed;
 750 "CCITT RLE" =&gt; CCITT 1D; "CCITT T.4" =&gt; Group 3 Fax; "CCITT T.6" =&gt; Group 4
 751 Fax; "LZW" =&gt; LZW; "Old JPEG" =&gt; JPEG; "JPEG" =&gt; New JPEG; "ZLib" =&gt; ZLib;
 752 "PackBits" =&gt; PackBits; "Deflate" =&gt; Deflate.</td>
 753 </tr>
 754 <tr>
 755 <td>PlanarConfiguration</td>
 756 <td>/Data/PlanarConfiguration@value: "PixelInterleaved" =&gt; Chunky;
 757 "PlaneInterleaved" =&gt; Planar.</td>
 758 </tr>
 759 <tr>
 760 <td>SampleFormat</td>
 761 <td>/Data/SampleFormat@value: "SignedIntegral" =&gt; two's complement signed
 762 integer data; "UnsignedIntegral" =&gt; unsigned integer data; "Real" =&gt;
 763 IEEE floating point data; "Index" =&gt; unsigned integer data.
 764 </td>
 765 </tr>
 766 <tr>
 767 <td>BitsPerSample</td>
 768 <td>/Data/BitsPerSample@value: space-separated list parsed to char array.</td>
 769 </tr>
 770 <tr>
 771 <td>FillOrder</td>
 772 <td>/Data/SampleMSB@value: if all values in space-separated list are 0s =&gt;
 773 right-to-left; otherwise =&gt; left-to-right.
 774 </td>
 775 </tr>
 776 <tr>
 777 <td>XResolution</td>
 778 <td>(10 / /Dimension/HorizontalPixelSize@value) or
 779 (10 / (/Dimension/VerticalPixelSize@value *
 780 /Dimension/PixelAspectRatio@value))</td>
 781 </tr>
 782 <tr>
 783 <td>YResolution</td>
 784 <td>(10 / /Dimension/VerticalPixelSize@value) or
 785 (10 / (/Dimension/HorizontalPixelSize@value /
 786 /Dimension/PixelAspectRatio@value))</td>
 787 </tr>
 788 <tr>
 789 <td>ResolutionUnit</td>
 790 <td>Centimeter if XResolution or YResolution set; otherwise None.</td>
 791 </tr>
 792 <tr>
 793 <td>Orientation</td>
 794 <td>/Dimension/ImageOrientation@value</td>
 795 </tr>
 796 <tr>
 797 <td>XPosition</td>
 798 <td>/Dimension/HorizontalPosition@value / 10</td>
 799 </tr>
 800 <tr>
 801 <td>YPosition</td>
 802 <td>/Dimension/VerticalPosition@value / 10</td>
 803 </tr>
 804 <tr>
 805 <td>NewSubFileType</td>
 806 <td>/Document/SubimageInterpretation@value: "TransparencyMask" =&gt;
 807 transparency mask; "ReducedResolution" =&gt; reduced-resolution;
 808 "SinglePage" =&gt; single page.</td>
 809 </tr>
 810 <tr>
 811 <td>DateTime</td>
 812 <td>/Document/ImageCreationTime@value</td>
 813 </tr>
 814 <tr>
 815 <td>DocumentName, ImageDescription, Make, Model, PageName, Software,
 816 Artist, HostComputer, InkNames, Copyright</td>
 817 <td>/Text/TextEntry: if /Text/TextEntry@keyword is the name of any of the
 818 TIFF Fields, e.g., "Software", then the field is added with content
 819 /Text/TextEntry@value and count 1.</td>
 820 </tr>
 821 <tr>
 822 <td>ExtraSamples</td>
 823 <td>/Transparency/Alpha@value: "premultiplied" =&gt; associated alpha, count 1;
 824 "nonpremultiplied" =&gt; unassociated alpha, count 1.</td>
 825 </tr>
 826 <tr>
 827 <td></td>
 828 <td></td>
 829 </tr>
 830 </table>
 831 
 832 <h3><a id="ExifWrite">Writing Exif Images</a></h3>
 833 
 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.
 836 
 837 <h4><a id="ExifWriteTIFF">Writing Uncompressed Exif Images</a></h4>
 838 
 839 When writing a sequence of images each image is normally recorded as
 840 {IFD,&nbsp;IFD Value,&nbsp;Image Data}. The Exif specification requires
 841 that an uncompressed Exif image be structured as follows:
 842 
 843 <a id="ExifStructure"></a>
 844 <ol>
 845 <li>Image File Header</li>
 846 <li>Primary IFD</li>
 847 <li>Primary IFD Value</li>
 848 <li>Thumbnail IFD</li>
 849 <li>Thumbnail IFD Value</li>
 850 <li>Thumbnail Image Data</li>
 851 <li>Primary Image Data</li>
 852 </ol>
 853 
 854 To meet the requirement of the primary image data being recorded last, the
 855 primary image must be written initially as an empty image and have its data
 856 added via pixel replacement after the thumbnail IFD and image data have been
 857 written:
 858 
 859 <pre><code>
 860     ImageWriter tiffWriter;
 861     ImageWriteParam tiffWriteParam;
 862     IIOMetadata tiffStreamMetadata;
 863     IIOMetadata primaryIFD;
 864     BufferedImage image;
 865     BufferedImage thumbnail;
 866 
 867     // Specify uncompressed output.
 868     tiffWriteParam.setCompressionMode(ImageWriteParam.MODE_DISABLED);
 869 
 870     if (thumbnail != null) {
 871         // Write the TIFF header.
 872         tiffWriter.prepareWriteSequence(tiffStreamMetadata);
 873 
 874         // Append the primary IFD.
 875         tiffWriter.prepareInsertEmpty(-1, // append
 876                 new ImageTypeSpecifier(image),
 877                 image.getWidth(),
 878                 image.getHeight(),
 879                 primaryIFD,
 880                 null, // thumbnails
 881                 tiffWriteParam);
 882         tiffWriter.endInsertEmpty();
 883 
 884         // Append the thumbnail image data.
 885         tiffWriter.writeToSequence(new IIOImage(thumbnail, null, null),
 886                 tiffWriteParam);
 887 
 888         // Insert the primary image data.
 889         tiffWriter.prepareReplacePixels(0, new Rectangle(image.getWidth(),
 890                 image.getHeight()));
 891         tiffWriter.replacePixels(image, tiffWriteParam);
 892         tiffWriter.endReplacePixels();
 893 
 894         // End writing.
 895         tiffWriter.endWriteSequence();
 896     } else {
 897         // Write only the primary IFD and image data.
 898         tiffWriter.write(tiffStreamMetadata,
 899                 new IIOImage(image, null, primaryIFD),
 900                 tiffWriteParam);
 901     }
 902 </code></pre>
 903 
 904 <h4><a id="ExifWriteJPEG">Writing Compressed Exif Images</a></h4>
 905 
 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">
 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.
 910 
 911 <pre><code>
 912     ImageWriter tiffWriter;
 913     ImageWriteParam tiffWriteParam;
 914     IIOMetadata tiffStreamMetadata;
 915     BufferedImage image;
 916     BufferedImage thumbnail;
 917     IIOMetadata primaryIFD;
 918     ImageOutputStream output;
 919 
 920     // Set up an output to contain the APP1 Exif TIFF stream.
 921     ByteArrayOutputStream baos = new ByteArrayOutputStream();
 922     MemoryCacheImageOutputStream app1ExifOutput =
 923         new MemoryCacheImageOutputStream(baos);
 924     tiffWriter.setOutput(app1ExifOutput);
 925 
 926     // Set compression for the thumbnail.
 927     tiffWriteParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
 928     tiffWriteParam.setCompressionType("Exif JPEG");
 929 
 930     // Write the APP1 Exif TIFF stream.
 931     if (thumbnail != null) {
 932         // Write the TIFF header.
 933         tiffWriter.prepareWriteSequence(tiffStreamMetadata);
 934 
 935         // Append the primary IFD.
 936         tiffWriter.prepareInsertEmpty(-1, // append
 937                 new ImageTypeSpecifier(image),
 938                 image.getWidth(),
 939                 image.getHeight(),
 940                 primaryIFD,
 941                 null, // thumbnails
 942                 tiffWriteParam);
 943         tiffWriter.endInsertEmpty();
 944 
 945         // Append the thumbnail IFD and image data.
 946         tiffWriter.writeToSequence(new IIOImage(thumbnail, null,
 947                 null), tiffWriteParam);
 948 
 949         // End writing.
 950         tiffWriter.endWriteSequence();
 951     } else {
 952         // Write only the primary IFD.
 953         tiffWriter.prepareWriteEmpty(tiffStreamMetadata,
 954                 new ImageTypeSpecifier(image),
 955                 image.getWidth(),
 956                 image.getHeight(),
 957                 primaryIFD,
 958                 null, // thumbnails
 959                 tiffWriteParam);
 960         tiffWriter.endWriteEmpty();
 961     }
 962 
 963     // Flush data into byte stream.
 964     app1ExifOutput.flush();
 965 
 966     // Create APP1 parameter array.
 967     byte[] app1Parameters = new byte[6 + baos.size()];
 968 
 969     // Add APP1 Exif ID bytes.
 970     app1Parameters[0] = (byte) 'E';
 971     app1Parameters[1] = (byte) 'x';
 972     app1Parameters[2] = (byte) 'i';
 973     app1Parameters[3] = (byte) 'f';
 974     app1Parameters[4] = app1Parameters[5] = (byte) 0;
 975 
 976     // Append TIFF stream to APP1 parameters.
 977     System.arraycopy(baos.toByteArray(), 0, app1Parameters, 6, baos.size());
 978 
 979     // Create the APP1 Exif node to be added to native JPEG image metadata.
 980     IIOMetadataNode app1Node = new IIOMetadataNode("unknown");
 981     app1Node.setAttribute("MarkerTag", String.valueOf(0xE1));
 982     app1Node.setUserObject(app1Parameters);
 983 
 984     // Append the APP1 Exif marker to the "markerSequence" node.
 985     IIOMetadata jpegImageMetadata =
 986         jpegWriter.getDefaultImageMetadata(new ImageTypeSpecifier(image),
 987             jpegWriteParam);
 988     String nativeFormat = jpegImageMetadata.getNativeMetadataFormatName();
 989     Node tree = jpegImageMetadata.getAsTree(nativeFormat);
 990     NodeList children = tree.getChildNodes();
 991     int numChildren = children.getLength();
 992     for (int i = 0; i &lt; numChildren; i++) {
 993         Node child = children.item(i);
 994         if (child.getNodeName().equals("markerSequence")) {
 995             child.appendChild(app1Node);
 996             break;
 997         }
 998     }
 999     jpegImageMetadata.setFromTree(nativeFormat, tree);
1000 
1001     // Write the JPEG image data including the APP1 Exif marker.
1002     jpegWriter.setOutput(output);
1003     jpegWriter.write(new IIOImage(image, null, jpegImageMetadata));
1004 </code></pre>
1005 
1006 The <code>"unknown"</code> node created above would be appended to the
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
1009 the JPEG writer.
1010 
1011 <h2><a id="StreamMetadata">Stream Metadata</a></h2>
1012 
1013 The DTD for the TIFF native stream metadata format is as follows:
1014 
1015 <pre>
1016 &lt;!DOCTYPE "javax_imageio_tiff_stream_1.0" [
1017 
1018   &lt;!ELEMENT "javax_imageio_tiff_stream_1.0" (ByteOrder)>
1019 
1020     &lt;!ELEMENT "ByteOrder" EMPTY&gt;
1021       &lt;!-- The stream byte order --&gt;
1022       &lt;!ATTLIST "ByteOrder" "value" #CDATA #REQUIRED&gt;
1023         &lt;!-- One of "BIG_ENDIAN" or "LITTLE_ENDIAN" --&gt;
1024         &lt;!-- Data type: String --&gt;
1025 ]&gt;
1026 </pre>
1027 
1028 <h2><a id="ImageMetadata">Image Metadata</a></h2>
1029 
1030 The DTD for the TIFF native image metadata format is as follows:
1031 
1032 <pre>
1033 &lt;!DOCTYPE "javax_imageio_tiff_image_1.0" [
1034 
1035   &lt;!ELEMENT "javax_imageio_tiff_image_1.0" (TIFFIFD)*&gt;
1036 
1037     &lt;!ELEMENT "TIFFIFD" (TIFFField | TIFFIFD)*&gt;
1038       &lt;!-- An IFD (directory) containing fields --&gt;
1039       &lt;!ATTLIST "TIFFIFD" "tagSets" #CDATA #REQUIRED&gt;
1040         &lt;!-- Data type: String --&gt;
1041       &lt;!ATTLIST "TIFFIFD" "parentTagNumber" #CDATA #IMPLIED&gt;
1042         &lt;!-- The tag number of the field pointing to this IFD --&gt;
1043         &lt;!-- Data type: Integer --&gt;
1044       &lt;!ATTLIST "TIFFIFD" "parentTagName" #CDATA #IMPLIED&gt;
1045         &lt;!-- A mnemonic name for the field pointing to this IFD, if known
1046              --&gt;
1047         &lt;!-- Data type: String --&gt;
1048 
1049       &lt;!ELEMENT "TIFFField" (TIFFBytes | TIFFAsciis |
1050         TIFFShorts | TIFFSShorts | TIFFLongs | TIFFSLongs |
1051         TIFFRationals | TIFFSRationals |
1052         TIFFFloats | TIFFDoubles | TIFFUndefined)&gt;
1053         &lt;!-- A field containing data --&gt;
1054         &lt;!ATTLIST "TIFFField" "number" #CDATA #REQUIRED&gt;
1055           &lt;!-- The tag number asociated with the field --&gt;
1056           &lt;!-- Data type: String --&gt;
1057         &lt;!ATTLIST "TIFFField" "name" #CDATA #IMPLIED&gt;
1058           &lt;!-- A mnemonic name associated with the field, if known --&gt;
1059           &lt;!-- Data type: String --&gt;
1060 
1061         &lt;!ELEMENT "TIFFBytes" (TIFFByte)*&gt;
1062           &lt;!-- A sequence of TIFFByte nodes --&gt;
1063 
1064           &lt;!ELEMENT "TIFFByte" EMPTY&gt;
1065             &lt;!-- An integral value between 0 and 255 --&gt;
1066             &lt;!ATTLIST "TIFFByte" "value" #CDATA #IMPLIED&gt;
1067               &lt;!-- The value --&gt;
1068               &lt;!-- Data type: String --&gt;
1069             &lt;!ATTLIST "TIFFByte" "description" #CDATA #IMPLIED&gt;
1070               &lt;!-- A description, if available --&gt;
1071               &lt;!-- Data type: String --&gt;
1072 
1073         &lt;!ELEMENT "TIFFAsciis" (TIFFAscii)*&gt;
1074           &lt;!-- A sequence of TIFFAscii nodes --&gt;
1075 
1076           &lt;!ELEMENT "TIFFAscii" EMPTY&gt;
1077             &lt;!-- A String value --&gt;
1078             &lt;!ATTLIST "TIFFAscii" "value" #CDATA #IMPLIED&gt;
1079               &lt;!-- The value --&gt;
1080               &lt;!-- Data type: String --&gt;
1081 
1082         &lt;!ELEMENT "TIFFShorts" (TIFFShort)*&gt;
1083           &lt;!-- A sequence of TIFFShort nodes --&gt;
1084 
1085           &lt;!ELEMENT "TIFFShort" EMPTY&gt;
1086             &lt;!-- An integral value between 0 and 65535 --&gt;
1087             &lt;!ATTLIST "TIFFShort" "value" #CDATA #IMPLIED&gt;
1088               &lt;!-- The value --&gt;
1089               &lt;!-- Data type: String --&gt;
1090             &lt;!ATTLIST "TIFFShort" "description" #CDATA #IMPLIED&gt;
1091               &lt;!-- A description, if available --&gt;
1092               &lt;!-- Data type: String --&gt;
1093 
1094         &lt;!ELEMENT "TIFFSShorts" (TIFFSShort)*&gt;
1095           &lt;!-- A sequence of TIFFSShort nodes --&gt;
1096 
1097           &lt;!ELEMENT "TIFFSShort" EMPTY&gt;
1098             &lt;!-- An integral value between -32768 and 32767 --&gt;
1099             &lt;!ATTLIST "TIFFSShort" "value" #CDATA #IMPLIED&gt;
1100               &lt;!-- The value --&gt;
1101               &lt;!-- Data type: String --&gt;
1102             &lt;!ATTLIST "TIFFSShort" "description" #CDATA #IMPLIED&gt;
1103               &lt;!-- A description, if available --&gt;
1104               &lt;!-- Data type: String --&gt;
1105 
1106         &lt;!ELEMENT "TIFFLongs" (TIFFLong)*&gt;
1107           &lt;!-- A sequence of TIFFLong nodes --&gt;
1108 
1109           &lt;!ELEMENT "TIFFLong" EMPTY&gt;
1110             &lt;!-- An integral value between 0 and 4294967295 --&gt;
1111             &lt;!ATTLIST "TIFFLong" "value" #CDATA #IMPLIED&gt;
1112               &lt;!-- The value --&gt;
1113               &lt;!-- Data type: String --&gt;
1114             &lt;!ATTLIST "TIFFLong" "description" #CDATA #IMPLIED&gt;
1115               &lt;!-- A description, if available --&gt;
1116               &lt;!-- Data type: String --&gt;
1117 
1118         &lt;!ELEMENT "TIFFSLongs" (TIFFSLong)*&gt;
1119           &lt;!-- A sequence of TIFFSLong nodes --&gt;
1120 
1121           &lt;!ELEMENT "TIFFSLong" EMPTY&gt;
1122             &lt;!-- An integral value between -2147483648 and 2147482647 --&gt;
1123             &lt;!ATTLIST "TIFFSLong" "value" #CDATA #IMPLIED&gt;
1124               &lt;!-- The value --&gt;
1125               &lt;!-- Data type: String --&gt;
1126             &lt;!ATTLIST "TIFFSLong" "description" #CDATA #IMPLIED&gt;
1127               &lt;!-- A description, if available --&gt;
1128               &lt;!-- Data type: String --&gt;
1129 
1130         &lt;!ELEMENT "TIFFRationals" (TIFFRational)*&gt;
1131           &lt;!-- A sequence of TIFFRational nodes --&gt;
1132 
1133           &lt;!ELEMENT "TIFFRational" EMPTY&gt;
1134             &lt;!-- A rational value consisting of an unsigned numerator and
1135                  denominator --&gt;
1136             &lt;!ATTLIST "TIFFRational" "value" #CDATA #IMPLIED&gt;
1137               &lt;!-- The numerator and denominator, separated by a slash --&gt;
1138               &lt;!-- Data type: String --&gt;
1139 
1140         &lt;!ELEMENT "TIFFSRationals" (TIFFSRational)*&gt;
1141           &lt;!-- A sequence of TIFFSRational nodes --&gt;
1142 
1143           &lt;!ELEMENT "TIFFSRational" EMPTY&gt;
1144             &lt;!-- A rational value consisting of a signed numerator and
1145                  denominator --&gt;
1146             &lt;!ATTLIST "TIFFSRational" "value" #CDATA #IMPLIED&gt;
1147               &lt;!-- The numerator and denominator, separated by a slash --&gt;
1148               &lt;!-- Data type: String --&gt;
1149 
1150         &lt;!ELEMENT "TIFFFloats" (TIFFFloat)*&gt;
1151           &lt;!-- A sequence of TIFFFloat nodes --&gt;
1152 
1153           &lt;!ELEMENT "TIFFFloat" EMPTY&gt;
1154             &lt;!-- A single-precision floating-point value --&gt;
1155             &lt;!ATTLIST "TIFFFloat" "value" #CDATA #IMPLIED&gt;
1156               &lt;!-- The value --&gt;
1157               &lt;!-- Data type: String --&gt;
1158 
1159         &lt;!ELEMENT "TIFFDoubles" (TIFFDouble)*&gt;
1160           &lt;!-- A sequence of TIFFDouble nodes --&gt;
1161 
1162           &lt;!ELEMENT "TIFFDouble" EMPTY&gt;
1163             &lt;!-- A double-precision floating-point value --&gt;
1164             &lt;!ATTLIST "TIFFDouble" "value" #CDATA #IMPLIED&gt;
1165               &lt;!-- The value --&gt;
1166               &lt;!-- Data type: String --&gt;
1167 
1168         &lt;!ELEMENT "TIFFUndefined" EMPTY&gt;
1169           &lt;!-- Uninterpreted byte data --&gt;
1170           &lt;!ATTLIST "TIFFUndefined" "value" #CDATA #IMPLIED&gt;
1171             &lt;!-- A list of comma-separated byte values --&gt;
1172             &lt;!-- Data type: String --&gt;
1173 ]&gt;
1174 </pre>
1175 
1176 @since 9
1177 </main>
1178 </body>
1179 </html>