--- old/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/jpeg_metadata.html 2017-10-23 13:51:06.000000000 -0700 +++ new/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/jpeg_metadata.html 2017-10-23 13:51:06.000000000 -0700 @@ -1,8 +1,11 @@ - - + + + + JPEG Metadata Format Specification and Usage Notes + -JPEG Metadata Format Specification and Usage Notes - - - + -

-JPEG Metadata Format Specification and Usage Notes -

+

JPEG Metadata Format Specification and Usage Notes

JPEG Metadata
@@ -46,11 +44,11 @@ Image Metadata DTD
Stream Metadata DTD

-NOTE: It is important to call dispose() -on the JPEG reader and writer objects when they are no longer needed, as -they consume significant native resources which are not adequately recovered -by garbage collection. Both reader and writer call dispose() -in their finalizers, but those finalizers may not be called before the native +NOTE: It is important to call dispose() +on the JPEG reader and writer objects when they are no longer needed, as +they consume significant native resources which are not adequately recovered +by garbage collection. Both reader and writer call dispose() +in their finalizers, but those finalizers may not be called before the native code has exhausted native memory.

@@ -58,45 +56,45 @@ The JPEG writer does not support replacing pixels.

-JPEG Metadata +JPEG Metadata

JPEG metadata consists of the data contained in marker segments in a JPEG stream. The image metadata object returned from a read describes the -contents of the marker segments between the SOI marker and -the EOI marker for that image. The image metadata object -passed into a write determines the contents of the stream between the -SOI marker and the EOI marker for that image, +contents of the marker segments between the SOI marker and +the EOI marker for that image. The image metadata object +passed into a write determines the contents of the stream between the +SOI marker and the EOI marker for that image, subject to the controls in any ImageWriteParam.

-Stream metadata is used only for tables-only images found (or to be -placed) at the beginning of a stream containing abbreviated images. -Tables-only images are not treated as images and do not consume an +Stream metadata is used only for tables-only images found (or to be +placed) at the beginning of a stream containing abbreviated images. +Tables-only images are not treated as images and do not consume an image index. The stream metadata object returned from a read describes the -contents of the marker segments between the SOI marker and -the EOI marker for the single tables-only image at the -beginning of the stream, if one is present. If no tables-only image is -present at the front of the stream, the getStreamMetadata -method of ImageReader returns null. If -stream metadata is provided to the writer, a single tables-only image -containing the tables from the stream metadata object will be written at +contents of the marker segments between the SOI marker and +the EOI marker for the single tables-only image at the +beginning of the stream, if one is present. If no tables-only image is +present at the front of the stream, the getStreamMetadata +method of ImageReader returns null. If +stream metadata is provided to the writer, a single tables-only image +containing the tables from the stream metadata object will be written at the beginning of the stream. If the stream metadata object contains no tables, default tables will be written. As the sole purpose of stream -metadata is for specifying tables-only images at the front of abbreviated -streams, the stream metadata argument is useful only on the -ImageWriter.prepareWriteSequence method. It is ignored on all +metadata is for specifying tables-only images at the front of abbreviated +streams, the stream metadata argument is useful only on the +ImageWriter.prepareWriteSequence method. It is ignored on all other methods. -

-The ImageWriter.getDefaultStreamMetadata method returns an -object containing the tables from the ImageWriteParam argument, -if it is a JPEGImageWriteParam and contains tables. Otherwise, +

+The ImageWriter.getDefaultStreamMetadata method returns an +object containing the tables from the ImageWriteParam argument, +if it is a JPEGImageWriteParam and contains tables. Otherwise, the returned object will contain default tables. -

The ImageWriter.getDefaultImageMetadata method returns a -metadata object containing no tables if the -ImageWriteParam argument contains tables. Otherwise the -returned metadata object will contain default visually lossless tables. +

The ImageWriter.getDefaultImageMetadata method returns a +metadata object containing no tables if the +ImageWriteParam argument contains tables. Otherwise the +returned metadata object will contain default visually lossless tables. Of course, only a JPEGImageWriteParam may contain tables.

@@ -105,59 +103,59 @@ metadata will.

-Abbreviated Streams +Abbreviated Streams

-Both the reader and the writer retain their tables from one operation to the -next, thus permitting the use of abbreviated streams quite naturally, with a -few minor restrictions: +Both the reader and the writer retain their tables from one operation to the +next, thus permitting the use of abbreviated streams quite naturally, with a +few minor restrictions:
    -
  1. Abbreviated streams may contain only one tables-only image, which must +
  2. Abbreviated streams may contain only one tables-only image, which must come first in the stream. Subsequent tables-only images will cause undefined behavior.
  3. Abbreviated streams must be read fully and in order. No random access - is allowed, in either direction. The same image may be read multiple + is allowed, in either direction. The same image may be read multiple times. If a call is made with an image index that is not the same as or one greater than the most recent call (or 0 if no calls have been made), then an IllegalArgumentException is thrown.
-These restrictions mean that streams may contain abbreviated images +These restrictions mean that streams may contain abbreviated images interspersed with images containing tables. As required by JPEG, any tables appearing in the stream override previous tables, regardless of the source -of the previous tables. +of the previous tables.

Note that once a tables-only image has been read, it's contents is available as stream metadata from the reader until either another tables-only image is read from another stream or the reader is reset. Changing the input does not reset the stream metadata. This is useful for reading the tables from -one file, then changing the input to read an abbreviated stream containing +one file, then changing the input to read an abbreviated stream containing a sequence of images. The tables will be used automatically, and will remain available as "stream" metadata.

-Abbreviated streams are written using the sequence methods of -ImageWriter. Stream metadata is used to write a tables-only +Abbreviated streams are written using the sequence methods of +ImageWriter. Stream metadata is used to write a tables-only image at the beginning of the stream, and the tables are set up for use, using -ImageWriter.prepareWriteSequence. If no stream metadata is -supplied to ImageWriter.prepareWriteSequence, then no +ImageWriter.prepareWriteSequence. If no stream metadata is +supplied to ImageWriter.prepareWriteSequence, then no tables-only image is written. If stream metadata containing no tables is supplied to ImageWriter.prepareWriteSequence, then a tables-only image containing default visually lossless tables is written.

-Sources of Tables +Sources of Tables

-Images are written with tables if tables are present in their metadata objects +Images are written with tables if tables are present in their metadata objects or without them if no tables are present in their metadata objects. If no -metadata object is present then the tables are written. The tables used for -compression are taken from one of the following sources, which are consulted -in order: +metadata object is present then the tables are written. The tables used for +compression are taken from one of the following sources, which are consulted +in order:

  1. If there is an ImageWriteParam and the compression mode is set to EXPLICIT, default tables constructed using the - quality setting are used. They are written only if the metadata - contains tables or if there is no metadata, but they replace the + quality setting are used. They are written only if the metadata + contains tables or if there is no metadata, but they replace the tables in the metadata.
  2. If there is an ImageWriteParam and the compression mode is set to DEFAULT, default visually lossles tables are used. @@ -176,39 +174,39 @@
-This ordering implements the design intention that tables should be included -in JPEGImageWriteParams only as a means of specifying tables +This ordering implements the design intention that tables should be included +in JPEGImageWriteParams only as a means of specifying tables when no other source is available, and this can occur only when writing to an -abbreviated stream without tables using known non-standard tables for +abbreviated stream without tables using known non-standard tables for compression.

-When reading, tables in a JPEGImageReadParam are consulted only -if tables have not been set by any previous read. Tables set from a -JPEGImageReadParam are overridden by any tables present in the +When reading, tables in a JPEGImageReadParam are consulted only +if tables have not been set by any previous read. Tables set from a +JPEGImageReadParam are overridden by any tables present in the stream being read.

-Note that if no image metadata object is specified for a particular image, a +Note that if no image metadata object is specified for a particular image, a default object is used, which includes default tables.

-Colorspace Transformations and Conventional Markers +Colorspace Transformations and Conventional Markers

Colorspace transformations are controlled by the destination type for both reading and writing of images. When Rasters are -read, no colorspace transformation is performed, and any destination type -is ignored. A warning is sent to any listeners if a destination type is -specified in this case. When Rasters are written, any +read, no colorspace transformation is performed, and any destination type +is ignored. A warning is sent to any listeners if a destination type is +specified in this case. When Rasters are written, any destination type is used to interpret the bands. This might result in a -JFIF or Adobe header being written, or different component ids being written -to the frame and scan headers. If values present in a metadata object do not -match the destination type, the destination type is used and a warning is sent +JFIF or Adobe header being written, or different component ids being written +to the frame and scan headers. If values present in a metadata object do not +match the destination type, the destination type is used and a warning is sent to any listeners.

-Optional ColorSpace support: +Optional ColorSpace support: Handling of PhotoYCC (YCC), PhotoYCCA (YCCA), RGBA and YCbCrA color spaces by the standard plugin, as described below, is dependent on capabilities of the libraries used to interpret the JPEG data. Thus all consequential @@ -219,7 +217,7 @@ When writing, an Exception may be thrown if no suitable conversion can be applied before encoding. But where the support for these color spaces is available, the behavior -must be as documented. +must be as documented.

When reading, the contents of the stream are interpreted by the usual @@ -232,7 +230,7 @@ the YCbCr is converted to RGB according to the formulas given in the JFIF spec, and the ICC profile is assumed to refer to the resulting RGB space. -

  • If an Adobe APP14 marker segment is present, the +
  • If an Adobe APP14 marker segment is present, the colorspace is determined by consulting the transform flag. The transform flag takes one of three values:
  • If neither marker segment is present, the following procedure is @@ -253,9 +251,9 @@ YCbCr. Subject to the availability of the optional color space support described above, if these values are 1-4 for a 4-channel image, - then the image is assumed to be YCbCrA. - If these values are > 4, they are checked - against the ASCII codes for 'R', 'G', 'B', 'A', 'C', 'c'. These can + then the image is assumed to be YCbCrA. + If these values are > 4, they are checked + against the ASCII codes for 'R', 'G', 'B', 'A', 'C', 'c'. These can encode the following colorspaces:


    RGB @@ -263,28 +261,28 @@
    YCC (as 'Y','C','c'), assumed to be PhotoYCC
    YCCA (as 'Y','C','c','A'), assumed to be PhotoYCCA

    - Otherwise, 3-channel subsampled images are assumed to be YCbCr, - 3-channel non-subsampled images are assumed to be RGB, 4-channel + Otherwise, 3-channel subsampled images are assumed to be YCbCr, + 3-channel non-subsampled images are assumed to be RGB, 4-channel subsampled images are assumed to be YCCK, and 4-channel, non-subsampled images are assumed to be CMYK.

  • All other images are declared uninterpretable and an exception is - thrown if an attempt is made to read one as a - BufferedImage. Such an image may be read only as a + thrown if an attempt is made to read one as a + BufferedImage. Such an image may be read only as a Raster. If an image is interpretable but there is no Java - ColorSpace available corresponding to the encoded - colorspace (e.g. YCbCr), then + ColorSpace available corresponding to the encoded + colorspace (e.g. YCbCr), then ImageReader.getRawImageType will return null. -Once an encoded colorspace is determined, then the target colorspace is +Once an encoded colorspace is determined, then the target colorspace is determined as follows: