JavaTM Advanced Imaging Image I/O Tools provides JAI read and write operations which use the Java Image I/O Framework, image input and output streams which use the New I/O APIs, and image reader and writer plug-ins.

See:
          Description

Packages
com.sun.media.imageio.plugins.bmp Package containing the public classes used by the Sun BMP plug-in for the Image I/O Framework.
com.sun.media.imageio.plugins.jpeg2000 Package containing the public classes used by the Sun JPEG 2000 plug-in for the Image I/O Framework.
com.sun.media.imageio.plugins.pnm Package containing the public classes used by the Sun PNM plug-in for the Image I/O Framework.
com.sun.media.imageio.plugins.tiff Package containing the public classes used by the TIFF plug-in for the Image I/O Framework.
com.sun.media.imageio.stream Provides ImageInputStream and ImageOutputStream classes for use with the Java Image I/O Framework.
com.sun.media.jai.operator Provides JAI operations which read and write images using the Java Image I/O Framework.

 

JavaTM Advanced Imaging Image I/O Tools provides JAI read and write operations which use the Java Image I/O Framework, image input and output streams which use the New I/O APIs, and image reader and writer plug-ins.

JAI Image I/O Operations

JAI operations which read and write images using the Java Image I/O Framework are provided in the package com.sun.media.jai.operator.

Java Image I/O Streams

Image I/O stream classes based on the new java.nio I/O APIs, for use with the "raw" format image reader plug-in, and for reading discontiguous image data are provided in the package com.sun.media.imageio.stream.

Java Image I/O Reader and Writer Plug-ins

Several reader and writer plug-ins for use with the Java Image I/O Framework are provided. A summary of their optional capabilities and metadata support is given in the following table where F denotes false, T indicates true, X signifies that the capability is irrelevant, and U is a variable which is true if and only if the image data are uncompressed. Capabilities not listed may be assumed to revert to the respective defaults for reading and writing.

Reader/Writer Plug-in Capability Summary
Capability BMP GIF JPEG JPEG 2000 PNG PNM Raw TIFF WBMP
ImageReader.canReadRaster() T X F T F T T F T
ImageReader.isRandomAccessEasy(int) U X F F F T T U T
ImageReader.readerSupportsThumbnails() F F T F F F F F F
ImageWriteParam.canWriteCompressed() T T T T T F F T F
ImageWriteParam.canWriteProgressive() F T F T T F F F F
ImageWriteParam.canWriteTiles() F F F T F F T T F
ImageWriter.canInsertEmpty(int) F F F F F F F T F
ImageWriter.canInsertImage(int) F F F F F F F T F
ImageWriter.canReplacePixels(int) F F F F F F F T F
ImageWriter.canWriteRasters() T F F T F T T F T
ImageWriter.canWriteEmpty() F F F F F F F T F
ImageWriter.canWriteSequence() F T F F F F F T F
Stream Metadata F T F F F F F T F
Standard Image Metadata T T T (reader only) T T T F T T (reader only)
Native Image Metadata T T T (reader only) T T T F T T (reader only)

BMP

ImageReader and ImageWriter plug-ins are provided for the Bitmap (BMP) format. A summary of the attributes of these plug-ins is given in the following table with more details in the description of the package com.sun.media.imageio.plugins.bmp.

BMP Reader/Writer Plug-in Attributes
Attribute Value
Format Name bmp
MIME Type image/bmp
Suffix bmp
Native Image Metadata com_sun_media_imageio_plugins_bmp_image_1.0
ImageWriteParam BMPImageWriteParam
References No formal, well-defined specification exists but the BMP - Windows Bitmap Format FAQ Entry contains useful information

GIF

An ImageWriter plug-in is provided for the Graphics Interchange Format (GIF). Animated GIF images may be created using the standard sequence writing methods defined in ImageWriter. By default the writer creates version "89a" images.

The writer supports setting output stream metadata from metadata supplied to the writer in either the native GIF stream metadata format javax_imageio_gif_stream_1.0 or the standard metadata format javax_imageio_1.0, and setting output image metadata from metadata supplied to the writer in either the native GIF image metadata format javax_imageio_gif_image_1.0 or the standard metadata format javax_imageio_1.0. The mapping of standard metadata format to the GIF native stream and image metadata formats is given in the tables below.

A global color table is written to the output stream if one of the following conditions obtains:

In the first case the global color table in the stream metadata is used, in the second the local color table in the image metadata is used, and in the third a global color table is created from the ColorModel or SampleModel of the (first) image.

A local color table is written to the output stream only if image metadata containing a LocalColorTable element are supplied to the writer, or no image metadata are supplied to the writer and the local color table which would be generated from the image itself is not equal to the global color table.

A Graphic Control Extension block is written to the output stream only if image metadata containing a GraphicControlExtension element are supplied to the writer, or no image metadata are supplied and the local color table generated from the image requires a transparent index. Application, Plain Text, and Comment Extension blocks are written only if they are supplied to the writer via image metadata.

Mapping of Standard to GIF Native Stream Metadata
Standard Metadata Component GIF Native Stream Metadata Component
/Chroma/Palette/PaletteEntry@index /GlobalColorTable/ColorTableEntry@index
/Chroma/Palette/PaletteEntry@red /GlobalColorTable/ColorTableEntry@red
/Chroma/Palette/PaletteEntry@green /GlobalColorTable/ColorTableEntry@green
/Chroma/Palette/PaletteEntry@blue /GlobalColorTable/ColorTableEntry@blue
/Chroma/BackgroundIndex@value /GlobalColorTable@backgroundColorIndex
/Data/BitsPerSample@value /LogicalScreenDescriptor@colorResolution
/Dimension/PixelAspectRatio@value /LogicalScreenDescriptor@pixelAspectRatio
/Dimension/HorizontalScreenSize@value /LogicalScreenDescriptor@logicalScreenWidth
/Dimension/VerticalScreenSize@value /LogicalScreenDescriptor@logicalScreenHeight
/Document/FormatVersion@value /Version@value

Mapping of Standard to GIF Native Image Metadata
Standard Metadata Component GIF Native Image Metadata Component
/Chroma/Palette/PaletteEntry@index /LocalColorTable/ColorTableEntry@index
/Chroma/Palette/PaletteEntry@red /LocalColorTable/ColorTableEntry@red
/Chroma/Palette/PaletteEntry@green /LocalColorTable/ColorTableEntry@green
/Chroma/Palette/PaletteEntry@blue /LocalColorTable/ColorTableEntry@blue
/Compression/NumProgressiveScans@value /ImageDescriptor@interlaceFlag
/Dimension/HorizontalPixelOffset@value /ImageDescriptor@imageLeftPosition
/Dimension/VerticalPixelOffset@value /ImageDescriptor@imageTopPosition
/Text/TextEntry@value /CommentExtensions/CommentExtension@value
/Transparency/TransparentIndex@value /GraphicControlExtension@transparentColorIndex (/GraphicControlExtension@transparentColorFlag is also set to "TRUE")

GIF Writer Plug-in Attributes
Attribute Value
Format Name gif
MIME Type image/gif
Suffix gif
ImageWriteParam ImageWriteParam subclass
References GIF 87a Specification (W3C page)

GIF ImageWriteParam Subclass Attributes
Attribute Value
Compression Types "LZW"
Compression Modes ImageWriteParam.MODE_DEFAULT, ImageWriteParam.MODE_EXPLICIT
Progressive Modes ImageWriteParam.MODE_COPY_FROM_METADATA (use metadata setting if provided, otherwise interlaced), ImageWriteParam.MODE_DEFAULT (interlaced), ImageWriteParam.MODE_DISABLED (not interlaced)
(MODE_COPY_FROM_METADATA is initial setting)

JPEG

ImageReader and ImageWriter plug-ins are provided for the JPEG image format. These plug-ins are accelerated using native code. If security permission settings disallow loading native code, or if the system property "com.sun.media.imageio.disableCodecLib" is set to "true" at the time of plug-in registration the service provider will deregister itself and the plug-ins will not be available.

In addition to providing better performance through native acceleration for conventional (lossy) JPEG (baseline sequential DCT, 8-bit sample precision), these plug-ins also support the following additional JPEG coding processes from ISO-10918-1/ITU-T.81:

as well as the following JPEG coding process from ISO-14495-1/ITU-T.87:

All subsampling and sub-banding is performed in memory, however, so if either is required, use of the core JPEG plug-in might be preferable. This plug-in performs best when the data are pixel interleaved with pixel stride equal to the number of samples per pixel and color component order G (grayscale), GA (grayscale with alpha), RGB (red-green-blue), BGR (blue-green-red), RGBA (red-green-blue with alpha), or CMYK (cyan-magenta-yellow-black) as appropriate for the color space. Other layouts will cause data to be reformatted in memory.

If the JPEG reader detects an ICC profile in an APP2 marker segment it will use it to define the raw ImageTypeSpecifier. If the inferred color space not based on the ICC profile is compatible with the ICC profile-based color space, then a second ImageTypeSpecifier derived from this inferred color space will be included in the Iterator returned by ImageReader.getImageTypes(int). If the iterator contains more than one type, the first one will be based on the ICC profile and the second on the inferred color space.

The JPEG reader supports TIFF native image metadata as an extra metadata format. If the JPEG stream contains an EXIF APP1 marker segment, the primary IFD contained therein will be available from the metadata tree extracted using the TIFF extra metadata format name. The IIOMetadata object returned by the JPEG reader may also be used in a call to TIFFDirectory.createFromMetadata() to create a TIFFDirectory instance from which TIFFFields may be easily extracted.

The JPEG reader supports thumbnails. These may be derived from JFIF APP0, JFXX APP0, or EXIF APP1 marker segments. Although APP0 marker segments are not allowed by the EXIF specification, there nevertheless exist EXIF images which contain them. If there is more than one thumbnail present, the JFIF thumbnail will be retrieved first, followed by any JFXX thumbnail(s), followed by any EXIF thumbnail. The source of each respective thumbnail may be determined by consulting the native image metadata.

The baseline DCT JPEG writer encodes images with from 1 to 4 bands. If the image is 4-banded with a ColorSpace of type ColorSpace.TYPE_CMYK, an Adobe APP14 marker with transform parameter value 0 will be written and the image components will not be subsampled.

JPEG Reader/Writer Plug-in Attributes
Attribute Value
Format Names jpeg, jpg, jpeg-lossless (ISO 10918-1 lossless), jpeg-ls (ISO 14495-1 lossless), jfif
MIME Type image/jpeg
Suffixes jpeg, jpg, jls (ISO 14495-1 lossless), jfif
Native Image Metadata javax_imageio_jpeg_1.0
Extra Image Metadata com_sun_media_imageio_plugins_tiff_image_1.0
ImageWriteParam ImageWriteParam subclass
References JPEG Home Page

JPEG ImageWriteParam Subclass Attributes
Attribute Value
Compression Types "JPEG" (conventional, lossy JPEG), "JPEG-LOSSLESS" (ISO-10918-1 lossless), "JPEG-LS" (ISO-14495-1 lossless)
Compression Modes ImageWriteParam.MODE_DEFAULT (lossy), ImageWriteParam.MODE_EXPLICIT
ImageWriteParam.isCompressionLossless() true if and only if compressionType is not "JPEG"

JPEG 2000

JavaTM and native-based ImageReader and ImageWriter plug-ins are provided for the JPEG 2000 image format. A summary of the attributes of these plug-ins is given in the table below with more details in the description of the package com.sun.media.imageio.plugins.jpeg2000. If security permission settings disallow loading native code, or if the system property "com.sun.media.imageio.disableCodecLib" is set to "true" at the time of plug-in registration the native service providers will deregister themselves and the native plug-ins will not be available. If both the native and JavaTM plug-ins are registered, the native plug-ins will have higher precedence in the IIORegistry.

JPEG 2000 Reader/Writer Plug-in Attributes
Attribute Value
Format Names jpeg2000, jpeg 2000
MIME Type image/jp2, image/jpeg2000
Suffix jp2
Native Image Metadata com_sun_media_imageio_plugins_jpeg2000_image_1.0
ImageReadParam J2KImageReadParam
ImageWriteParam J2KImageWriteParam
References JPEG 2000 Links

PNG

ImageReader and ImageWriter plug-ins are provided for the Portable Network Graphics (PNG) image format. These plug-ins are accelerated using native code. If security permission settings disallow loading native code, or if the system property "com.sun.media.imageio.disableCodecLib" is set to "true" at the time of plug-in registration the service provider will deregister itself and the plug-ins will not be available.

In addition to providing better performance through native acceleration, these plug-ins also provide the ability to set the compression level and encoder strategy. All subsampling and sub-banding is performed in memory, however, so if either of these is required, use of the core PNG plug-in might be preferable. This plug-in performs best when the data are either packed bilevel (1 sample per pixel, 1 bit per sample) or pixel interleaved with pixel stride equal to the number of samples per pixel and color component order G (grayscale), GA (grayscale with alpha), RGB (red-green-blue), or RGBA (red-green-blue with alpha) as appropriate for the color space. Other layouts will cause data to be reformatted in memory. Currently only bit depths of 1, 8, and 16 are supported.

If the PNG reader detects an ICC profile in an iCCP chunk it will use it to define the raw ImageTypeSpecifier. If the inferred color space not based on the ICC profile field is compatible with the ICC profile-based color space, then a second ImageTypeSpecifier derived from this inferred color space will be included in the Iterator returned by ImageReader.getImageTypes(int). If the iterator contains more than one type, the first one will be based on the ICC profile and the second on the inferred color space.

The PNG writer will write an iCCP chunk to the output if one is in the native image metadata object provided to the writer, or if the ColorSpace of the ColorModel of the destination ImageTypeSpecifier is based on an ICC profile which is not one of the standard ColorSpaces corresponding to the ColorSpace.cs_* constants. The destination type is set via ImageWriteParam.setDestinationType() and defaults to the ImageTypeSpecifier of the image being written.

PNG Reader/Writer Plug-in Attributes
Attribute Value
Format Name png
MIME Type image/png
Suffix png
Native Image Metadata javax_imageio_png_1.0
ImageWriteParam ImageWriteParam subclass
References W3C PNG Page

PNG ImageWriteParam Subclass Attributes
Attribute Value
Compression Types "DEFAULT", "FILTERED", "HUFFMAN_ONLY"
Compression Modes ImageWriteParam.MODE_DEFAULT, ImageWriteParam.MODE_EXPLICIT, ImageWriteParam.MODE_COPY_FROM_METADATA (initial setting).
Compression Quality Sets compression level as compressionLevel = (int)(9*(1.0F - compressionQuality))
Progressive Modes ImageWriteParam.MODE_DEFAULT ("Adam7" interlacing), ImageWriteParam.MODE_DISABLED (no interlacing), ImageWriteParam.MODE_COPY_FROM_METADATA (initial setting).

Mapping Between Standard and Native PNG Image Metadata
Standard Metadata Component PNG Native Image Metadata Component
/Chroma/ColorSpaceType@name /IHDR@colorType
/Chroma/NumChannels@value /IHDR@colorType, /tRNS
/Chroma/Gamma@value /gAMA@gamma
/Chroma/BlackIsZero@value Always "TRUE"
/Chroma/Palette /PLTE
/Chroma/Palette/PaletteEntry@red /PLTE/PLTEEntry@red
/Chroma/Palette/PaletteEntry@green /PLTE/PLTEEntry@green
/Chroma/Palette/PaletteEntry@blue /PLTE/PLTEEntry@blue
/Chroma/Palette/PaletteEntry@alpha /PLTE/PLTEEntry@alpha
/Chroma/BackgroundIndex@value /bKGD/bKGD_Palette@index
/Chroma/BackgroundColor@red /bKGD/bKGD_RGB@red or /bKGD/bKGD_Grayscale@gray
/Chroma/BackgroundColor@green /bKGD/bKGD_RGB@green or /bKGD/bKGD_Grayscale@gray
/Chroma/BackgroundColor@blue /bKGD/bKGD_RGB@blue or /bKGD/bKGD_Grayscale@gray
/Compression/CompressionTypeName@value Always "deflate"
/Compression/Lossless@value Always "TRUE"
/Compression/NumProgressiveScans@value /IHDR/interlaceMethod@value
/Data/PlanarConfiguration@value Always "PixelInterleaved"
/Data/SampleFormat@value /IHDR@colorType
/Data/BitsPerSample@value /IHDR@bitDepth, /IHDR@colorType, /tRNS
/Data/SignificantBitsPerSample@value /sBIT
/Dimension/PixelAspectRatio@value /pHYs@pixelsPerUnitYAxis//pHYs@pixelsPerUnitXAxis or 1.0
/Dimension/ImageOrientation@value Always "Normal"
/Dimension/HorizontalPixelSize@value /pHYs@pixelsPerUnitXAxis, /pHYS@unitSpecifier
/Dimension/VerticalPixelSize@value /pHYs@pixelsPerUnitYAxis, /pHYS@unitSpecifier
/Document/ImageModificationTime@value /tIME
/Text/TextEntry /tEXt, /iTXt, /zTXt
/Transparency/Alpha@value /IHDR@colorType, /tRNS@alpha
/Transparency/TransparentColor@value /tRNS

PNM

ImageReader and ImageWriter plug-ins are provided for the "portable anymap" (PNM) image format which refers collectively to the formats PBM (portable bitmap), PGM (portable graymap), and PPM (portable pixmap). A summary of the attributes of these plug-ins is given in the following table with more details in the description of the package com.sun.media.imageio.plugins.pnm.

PNM Reader/Writer Plug-in Attributes
Attribute Value
Format Name pnm
MIME Types image/x-portable-anymap, image/x-portable-bitmap image/x-portable-graymap,image/x-portable-pixmap
Suffixes pbm, pgm, ppm
Native Image Metadata com_sun_media_imageio_plugins_pnm_image_1.0
ImageWriteParam PNMImageWriteParam
References The Netpbm Formats,
Manpage of pbm,
Manpage of pgm,
Manpage of ppm

Raw

ImageReader and ImageWriter plug-ins are provided for the "raw" image format. The ImageReader plug-in for the "raw" format requires an input which is a RawImageInputStream.

The reader plug-in reads any uncompressed data defined by ComponentSampleModel, SinglePixelPackedSampleModel or MultiPixelPackedSampleModel as viewed via the ImageInputStream. For example, if extra data are prepended or appended to image lines, SegmentedImageInputStream may be used to define the location of the image data for each line. Thus, if the data viewed from RawImageInputStream are defined by the SampleModels above after RawImageInputStream is chained with SegmentedImageInputStream, the reader plug-in can decode these data correctly.

The writer plug-in writes the data to the stream exactly as defined by the SampleModel. If the SampleModel has a scanline stride associated with it, this will be used to determine the length of each line written. If only the actual image data and not any prefix or suffix data on the line are to be written and the scanline stride is greater than the SampleModel width multiplied by the number of bands, the image should first be reformatted to remove the extra data. If JAI is available the "Format" operation may be used for reformatting the data.

Raw Reader/Writer Plug-in Attributes
Attribute Value
Format Name raw
MIME Type none
Suffix none
ImageWriteParam ImageWriteParam subclass
References XML InputSource defined at RawImageInputStream.RawImageInputStream(javax.imageio.stream.ImageInputStream,org.xml.sax.InputSource)

Raw ImageWriteParam Subclass Attributes
Attribute Value
Tiling Modes ImageWriteParam.MODE_DEFAULT

TIFF

ImageReader and ImageWriter plug-ins are provided for the Tag(ged) Image File Format (TIFF). A summary of the attributes of these plug-ins is given in the table below with more details in the description of the package com.sun.media.imageio.plugins.tiff. Native code is used to accelerate bilevel encodings. If security permission settings disallow loading native code, or if the system property "com.sun.media.imageio.disableCodecLib" is set to "true" at the time of (de)compression, native acceleration will not be used.

TIFF Reader/Writer Plug-in Attributes
Attribute Value
Format Names tif, tiff
MIME Type image/tiff
Suffixes tif, tiff
Native Stream Metadata com_sun_media_imageio_plugins_tiff_stream_1.0
Native Image Metadata com_sun_media_imageio_plugins_tiff_image_1.0
ImageReadParam TIFFImageReadParam
ImageWriteParam TIFFImageWriteParam
References TIFF 6.0 Specification (PDF),
TIFF Specification Supplement 1 (PDF),
TIFF Specification Supplement 2 (PDF) (covers ZLIB and JPEG compression in TIFF),
The Unofficial TIFF Home Page,
TIFF Software (libtiff),
TIFF-F Revised Specification,
JPEG-in-TIFF compression,
DEFLATE specification (Zip-in-TIFF),
ZLIB specification (Zip-in-TIFF),
ICC Specification (PDF): section B.4: Embedding ICC profiles in TIFF files,
EXIF and related resources

WBMP

ImageReader and ImageWriter plug-ins are provided for the Wireless Bitmap (WBMP) image format. A summary of the attributes of these plug-ins is given in the following table.

WBMP Reader/Writer Plug-in Attributes
Attribute Value
Format Name wbmp
MIME Type image/vnd.wap.wbmp
Suffix wbmp
Native Image Metadata com_sun_media_imageio_plugins_wbmp_image_1.0
References WAP Media Types Specification (PDF) available from WAP Forum Specifications and Open Mobile Alliance

Image Metadata

The XML schema for the WBMP native image metadata format is as follows:
<?xml version="1.0" encoding="UTF-8"?>

<!-- Schema for WBMP native image metadata format. -->

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://com.sun.media.imageio.plugins"
            targetNamespace="http://com.sun.media.imageio.plugins">

  <!-- WBMP Schema 1.0 root element. -->
  <xsd:element name="com_sun_media_imageio_plugins_wbmp_image_1.0">
    <xsd:complexType>
      <xsd:sequence>

        <!-- WBMP type -->
        <xsd:element name="WBMPType" type="xsd:unsignedInt"/>

        <!-- Bitmap width -->
        <xsd:element name="Width" type="xsd:unsignedInt"/>

        <!-- Bitmap height -->
        <xsd:element name="Height" type="xsd:unsignedInt"/>

      </xsd:sequence>
    </xsd:complexType>
  </xsd:element> <!-- wbmp_image_1.0 -->

</xsd:schema>

Since:
1.0