Overview | Package | Class | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package com.sun.media.imageio.plugins.tiff

Package containing the public classes used by the Sun TIFF plug-in for the Image I/O Framework.

See:
Description

Class Summary
BaselineTIFFTagSet | A class representing the set of tags found in the baseline TIFF specification as well as some common additional tags.
EXIFParentTIFFTagSet | A class containing the TIFF tag used to reference an EXIF IFD.
EXIFTIFFTagSet | A class representing the tags found in an EXIF IFD.
FaxTIFFTagSet | A class representing the extra tags found in a TIFF-F (RFC 2036) file.
GeoTIFFTagSet | A class representing the tags found in a GeoTIFF IFD.
TIFFColorConverter | An abstract class that performs simple color conversion on 3-banded source images, for use with the TIFF ImageIO plug-in.
TIFFCompressor | An abstract superclass for pluggable TIFF compressors.
TIFFDecompressor | A class defining a pluggable TIFF decompressor.
TIFFImageReadParam | A subclass of `ImageReadParam` allowing control over the TIFF reading process.
TIFFImageWriteParam | A subclass of ``ImageWriteParam`` allowing control over the standard TIFF compression types.
TIFFTag | A class defining the notion of a TIFF tag.
TIFFTagSet | A class representing a set of TIFF tags.

## Package com.sun.media.imageio.plugins.tiff Description

Package containing the public classes used by the Sun TIFF plug-in for the Image I/O Framework.

### Reading Images

TIFF images are read by an `ImageReader` which may be controlled by its public interface as well as via a supplied `TIFFImageReadParam`.

#### Decompression

A `TIFFDecompressor` object may be supplied via `TIFFImageReadParam.setTIFFDecompressor(com.sun.media.imageio.plugins.tiff.TIFFDecompressor)`. If a `TIFFDecompressor` is specified in this manner it will be used and will supersede any internal decompressor which might otherwise have been used for a known compression type. This mechanism allows for compression types to be handled by user-defined decompressors whether or not that compression type is known to the plug-in.

#### Color Conversion

A `TIFFColorConverter` object may be supplied via `TIFFImageReadParam.setColorConverter(com.sun.media.imageio.plugins.tiff.TIFFColorConverter)`. If a `TIFFColorConverter` is specified in this manner it will be used and will supersede any internal color converter which might otherwise have been used. This color converter will be used to convert the source image data to an RGB color space.

If no user-supplied color converter is available, the source image data have photometric type CIE L*a*b* or YCbCr, and the destination color space type is RGB, then the source image data will be automatically converted to RGB using an internal color converter.

#### Color Spaces

The raw color space assigned by default, i.e., in the absence of a user-supplied `ImageTypeSpecifier`, will be the first among the following which applies:

- sRGB if the image is monochrome/bilevel (a two-level color map is created internally).
- sRGB if the image is palette-color.
- Linear RGB if the image has three samples per pixel, has photometric type CIE L*a*b*, or has photometric type YCbCr and is not JPEG-compressed.
- A generic CMYK color space if the image has photometric type CMYK and four samples per pixel.
- Grayscale if the image has one or two samples per pixel.
- sRGB if the image has three or four samples per pixel.
- A fabricated, generic color space if the image has more than four samples per pixel and the number of bits per sample for all bands is the same and is a multiple of 8.

The normalized color coordinate transformations used for the default CMYK color space are defined as follows:

    R = 1.0 - (C - K)
    G = 1.0 - (M - K)
    B = 1.0 - (Y - K)

    C = 1.0 - R
    M = 1.0 - G
    Y = 1.0 - B
    K = min{C,M,Y}

The generic color space used when no other color space can be inferred is provided merely to enable the data to be loaded. It is not intended to provide accurate conversions of any kind.

If the data are known to be in a color space not correctly handled by the foregoing, then an `ImageTypeSpecifier` should be supplied to the reader and should be derived from a color space which is correct for the data in question.

#### ICC Profiles

If an ICC profile is contained in the image metadata (`BaselineTIFFTagSet.TAG_ICC_PROFILE`, tag number 34675), it will not automatically be used to create the color space of the loaded image. If it is desired that the embedded ICC profile be used then the following procedure is recommended:

1. Obtain the image metadata from `ImageReader.getImageMetadata(int)`
2. Extract the ICC profile field and its value.
3. Create an `ICC_ColorSpace` from an `ICC_Profile` created from the ICC profile field data using `ICC_Profile.getInstance(byte[])`.
4. Create an `ImageTypeSpecifier` from the new color space using one of its factory methods which accepts an `ICC_ColorSpace`.
5. Create a compatible `ImageReadParam` and set the `ImageTypeSpecifier` using `ImageReadParam.setDestinationType(javax.imageio.ImageTypeSpecifier)`.
6. Pass the parameter object to the appropriate `read` method.

### Writing Images

TIFF images are read by an `ImageWriter` which may be controlled by its public interface as well as via a supplied `TIFFImageWriteParam`.

#### Compression

A `TIFFCompressor` object may be supplied via `TIFFImageWriteParam.setTIFFCompressor(com.sun.media.imageio.plugins.tiff.TIFFCompressor)`. If a `TIFFCompressor` is specified in this manner it will be used and will supersede any internal compressor which might otherwise have been used for a known compression type. This mechanism allows for compression types to be handled by user-defined compressors whether or not that compression type is known to the plug-in.

#### Color Conversion

A `TIFFColorConverter` object may be supplied via `TIFFImageWriteParam.setColorConverter(com.sun.media.imageio.plugins.tiff.TIFFColorConverter, int)`. If a `TIFFColorConverter` is specified in this manner it will be used and will supersede any internal color converter which might otherwise have been used. This color converter will be used to convert from RGB to the color space of the output image.

If no user-supplied color converter is available, the source image data color space type is RGB, and the destination photometric type is CIE L*a*b* or YCbCr, then the source image data will be automatically converted from RGB using an internal color converter.

#### Metadata Issues

Some behavior of the writer is affected by or may affect the contents of the image metadata which may be supplied by the user.

For bilevel images, the `FillOrder`, and `T4Options` fields affect the output data. The data will be filled right-to-left if `FillOrder` is present with a value of 2 (`BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT`) and will be filled left-to-right otherwise. The value of `T4Options` specifies whether the data should be 1D- or 2D-encoded and whether EOL padding should be used.

For all images the value of the `RowsPerStrip` field is used to the set the number of rows per strip if the image is not tiled. The default number of rows per strip is either 8 or the number of rows which would fill no more than 8 kilobytes, whichever is larger.

For all images the tile dimensions may be set using the `TileWidth` and `TileLength` field values if the tiling mode is `ImageWriteParam.MODE_COPY_FROM_METADATA`. If this mode is set but the fields are not, their respective default values are the image width and height.

Some fields may be removed or modified:

- `BitsPerSample` if the image is not bilevel.
- `ExtraSamples` if the image does not have an alpha channel.
- `ColorMap` if the photometric interpretation is not `PaletteColor`.
- `TileWidth` and `TileLength` if tiling is not being used.
- `RowsPerStrip` if tiling is being used.
- `YCbCrSubsampling` and `YCbCrPositioning` if the photometric interpretation is YCbCr and the compression type is not JPEG (only [1, 1] subsampling and cosited positioning are supported for non-JPEG YCbCr output).
- `YCbCrSubsampling`, `YCbCrPositioning`, and `ReferenceBlackWhite` if the compression type is JPEG. If the color space is grayscale these will be removed. If the color space is RGB these will be reset to [2, :2] centered subsampling with no headroom/footroom (0:255,128:255,128:255).

Other fields present in the supplied metadata are uninterpreted and will be written as supplied.

As for reading, the ICC profile field is not handled automatically. If an ICC profile field is desired in the output metadata then it should be supplied to the writer.

### Stream Metadata

The DTD for the stream metadata format is as follows:

    <!DOCTYPE "com_sun_media_imageio_plugins_tiff_stream_1.0" [

      <!ELEMENT "com_sun_media_imageio_plugins_tiff_stream_1.0" (ByteOrder)>

        <!ELEMENT "ByteOrder" EMPTY>
          <!-- The stream byte order -->
          <!ATTLIST "ByteOrder" "value" #CDATA #REQUIRED>
            <!-- One of "BIG_ENDIAN" or "LITTLE_ENDIAN" -->
            <!-- Data type: String -->
    ]>

### Image Metadata

The DTD for the native image metadata format is as follows:

    <!DOCTYPE "com_sun_media_imageio_plugins_tiff_image_1.0" [

      <!ELEMENT "com_sun_media_imageio_plugins_tiff_image_1.0" (TIFFIFD)*>

        <!ELEMENT "TIFFIFD" (TIFFField | TIFFIFD)*>
          <!-- An IFD (directory) containing fields -->
          <!ATTLIST "TIFFIFD" "tagSets" #CDATA #REQUIRED>
            <!-- Data type: String -->
          <!ATTLIST "TIFFIFD" "parentTagNumber" #CDATA #IMPLIED>
            <!-- The tag number of the field pointing to this IFD -->
            <!-- Data type: Integer -->
          <!ATTLIST "TIFFIFD" "parentTagName" #CDATA #IMPLIED>
            <!-- A mnemonic name for the field pointing to this IFD, if known
                 -->
            <!-- Data type: String -->

          <!ELEMENT "TIFFField" (TIFFByte | TIFFBytes | TIFFAscii |
            TIFFAsciis | TIFFShort | TIFFShorts | TIFFSShort | TIFFSShorts |
            TIFFLong | TIFFLongs | TIFFSLong | TIFFSLongs | TIFFRational |
            TIFFRationals | TIFFSRational | TIFFSRationals | TIFFFloat |
            TIFFFloats | TIFFDouble | TIFFDoubles | TIFFUndefined)>
            <!-- A field containing data -->
            <!ATTLIST "TIFFField" "number" #CDATA #REQUIRED>
              <!-- The tag number asociated with the field -->
              <!-- Data type: String -->
            <!ATTLIST "TIFFField" "name" #CDATA #IMPLIED>
              <!-- A mnemonic name associated with the field, if known -->
              <!-- Data type: String -->

            <!ELEMENT "TIFFByte" EMPTY>
              <!-- An integral value between 0 and 255 -->
              <!ATTLIST "TIFFByte" "value" #CDATA #IMPLIED>
                <!-- The value -->
                <!-- Data type: String -->
              <!ATTLIST "TIFFByte" "description" #CDATA #IMPLIED>
                <!-- A description, if available -->
                <!-- Data type: String -->

            <!ELEMENT "TIFFBytes" (TIFFByte)*>
              <!-- A sequence of TIFFByte nodes -->

            <!ELEMENT "TIFFAscii" EMPTY>
              <!-- A String value -->
              <!ATTLIST "TIFFAscii" "value" #CDATA #IMPLIED>
                <!-- The value -->
                <!-- Data type: String -->

            <!ELEMENT "TIFFAsciis" (TIFFAscii)*>
              <!-- A sequence of TIFFAscii nodes -->

            <!ELEMENT "TIFFShort" EMPTY>
              <!-- An integral value between 0 and 65535 -->
              <!ATTLIST "TIFFShort" "value" #CDATA #IMPLIED>
                <!-- The value -->
                <!-- Data type: String -->
              <!ATTLIST "TIFFShort" "description" #CDATA #IMPLIED>
                <!-- A description, if available -->
                <!-- Data type: String -->

            <!ELEMENT "TIFFShorts" (TIFFShort)*>
              <!-- A sequence of TIFFShort nodes -->

            <!ELEMENT "TIFFSShort" EMPTY>
              <!-- An integral value between -32768 and 32767 -->
              <!ATTLIST "TIFFSShort" "value" #CDATA #IMPLIED>
                <!-- The value -->
                <!-- Data type: String -->
              <!ATTLIST "TIFFSShort" "description" #CDATA #IMPLIED>
                <!-- A description, if available -->
                <!-- Data type: String -->

            <!ELEMENT "TIFFSShorts" (TIFFSShort)*>
              <!-- A sequence of TIFFSShort nodes -->

            <!ELEMENT "TIFFLong" EMPTY>
              <!-- An integral value between 0 and 4294967295 -->
              <!ATTLIST "TIFFLong" "value" #CDATA #IMPLIED>
                <!-- The value -->
                <!-- Data type: String -->
              <!ATTLIST "TIFFLong" "description" #CDATA #IMPLIED>
                <!-- A description, if available -->
                <!-- Data type: String -->

            <!ELEMENT "TIFFLongs" (TIFFLong)*>
              <!-- A sequence of TIFFLong nodes -->

            <!ELEMENT "TIFFSLong" EMPTY>
              <!-- An integral value between -2147483648 and 2147482647 -->
              <!ATTLIST "TIFFSLong" "value" #CDATA #IMPLIED>
                <!-- The value -->
                <!-- Data type: String -->
              <!ATTLIST "TIFFSLong" "description" #CDATA #IMPLIED>
                <!-- A description, if available -->
                <!-- Data type: String -->

            <!ELEMENT "TIFFSLongs" (TIFFSLong)*>
              <!-- A sequence of TIFFSLong nodes -->

            <!ELEMENT "TIFFRational" EMPTY>
              <!-- A rational value consisting of an unsigned numerator and
                   denominator -->
              <!ATTLIST "TIFFRational" "value" #CDATA #IMPLIED>
                <!-- The numerator and denominator, separated by a slash -->
                <!-- Data type: String -->

            <!ELEMENT "TIFFRationals" (TIFFRational)*>
              <!-- A sequence of TIFFRational nodes -->

            <!ELEMENT "TIFFSRational" EMPTY>
              <!-- A rational value consisting of a signed numerator and
                   denominator -->
              <!ATTLIST "TIFFSRational" "value" #CDATA #IMPLIED>
                <!-- The numerator and denominator, separated by a slash -->
                <!-- Data type: String -->

            <!ELEMENT "TIFFSRationals" (TIFFSRational)*>
              <!-- A sequence of TIFFSRational nodes -->

            <!ELEMENT "TIFFFloat" EMPTY>
              <!-- A single-precision floating-point value -->
              <!ATTLIST "TIFFFloat" "value" #CDATA #IMPLIED>
                <!-- The value -->
                <!-- Data type: String -->

            <!ELEMENT "TIFFFloats" (TIFFFloat)*>
              <!-- A sequence of TIFFFloat nodes -->

            <!ELEMENT "TIFFDouble" EMPTY>
              <!-- A double-precision floating-point value -->
              <!ATTLIST "TIFFDouble" "value" #CDATA #IMPLIED>
                <!-- The value -->
                <!-- Data type: String -->

            <!ELEMENT "TIFFDoubles" (TIFFDouble)*>
              <!-- A sequence of TIFFDouble nodes -->

            <!ELEMENT "TIFFUndefined" EMPTY>
              <!-- Uninterpreted byte data -->
              <!ATTLIST "TIFFUndefined" "value" #CDATA #IMPLIED>
                <!-- A list of comma-separated byte values -->
                <!-- Data type: String -->
    ]>

Since:
  1.0

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES