JNG (JPEG Network Graphics) Format Version 19981111

file: draft-jng-53-19981111.txt

Extracted from Draft 53, file: draft-mng-53-19981111.txt

MNG (Multiple-image Network Graphics) Format Version 19981111

ftp://swrinde.nde.swri.edu/pub/mng/documents/.

Status of this Memo

This document is an informal draft of the PNG development group.

It is a proposal, and the format is subject to change.

Comments on this document can be sent to the PNG specification maintainers at one of the following addresses:

Distribution of this memo is unlimited.

At present, the latest version of this document is available on the World Wide Web from

   ftp://swrinde.nde.swri.edu/pub/mng/documents/.

In the case of any discrepancy between this extract and the full MNG specification, the full MNG specification shall take precedence.

Changes from fifty-second MNG draft (draft-52-mng-19981109)

Abstract

This document presents the format of a JNG (JPEG Network Graphics) datastream. JNG is a lossy single-image member of the PNG (Portable Network Graphics) format family. It encapsulates a JPEG datastream in PNG-style chunks, along with an optional alpha channel and ancillary chunks that carry color-space information and comments. While JNG is primarily intended as a subformat of the MNG (Multiple-image Network Graphics) format, standalone JNG files are also possible.

1. The JPEG Network Graphics (JNG) Format

JNG (JPEG Network Graphics) is the lossy sub-format for MNG objects.

Note: This specification depends on the PNG Portable Network Graphics specification [PNG]. The PNG specification is available at the PNG home page,

   http://www.cdrom.com/pub/png/

A JNG datastream consists of a header chunk (JHDR), JDAT chunks that contain a complete JPEG datastream, and optionally, IDAT chunks that contain a PNG-encoded grayscale image that is to be used as an alpha mask. Such a mask must have the same dimensions as the image itself. The JDAT and IDAT chunks can be interleaved. Some of the PNG ancillary chunks are also recognized in JNG datastreams.

While JNG is primarily intended for use as a sub-format within MNG, a single-image JNG datastream can be written in a standalone file. If so, the first eight bytes of a JNG datastream are

   139 80 78 74 13 10 26 10

(decimal) which is similar to the PNG signature with "\213 J N G" instead of "\211 P N G" in bytes 0-3.

JNG is pronounced "Jing" [or "J N G" in the local language pronunciation of Roman letters].

1.1. JNG critical chunks

This section specifies the critical chunks that are defined in the JNG format.

1.1.1. JHDR JNG header

The format of the JHDR chunk introduces a JNG datastream. It contains:

   Width:      4 bytes (unsigned integer, range 0..65535).
   Height:     4 bytes (unsigned integer, range 0..65535).
   Color type: 1 byte
                 8: Gray (Y).
                10: Color (YCbCr).
                12: Gray-alpha (Y-alpha).
                14: Color-alpha (YCbCr-alpha).
   
   JDAT sample
     depth:    1 byte
                 8: 8-bit samples and quantization tables.
                12: 12-bit samples and quantization
                    tables.
                20: 8-bit image followed by a 12-bit
                    image.
   
   JDAT compression
     method:   1 byte
                 8: ISO-10918-1 Huffman-coded baseline JPEG.
   
   JDAT interlace
     method:   1 byte.
                 0: Sequential JPEG, single scan.
                 8: Progressive JPEG.
   
   IDAT sample
     depth:    1 byte.
                 0, 1, 2, 4, 8, or 16.
   
   IDAT compression
     method:   1 byte.
                 0: Zlib DEFLATE.
   
   IDAT filter
     method:   1 byte.
                 0: Adaptive (see PNG spec).
   
   IDAT interlace
     method:   1 byte.
                 0: Not interlaced.

The width, height, JDAT_sample_depth, JDAT_compression_method, and JDAT_interlace_method fields are redundant because equivalent information is also embedded in the JDAT datastream. They appear in the JHDR chunk for convenience. Their values must be identical to their equivalents embedded in the JDAT chunk. We use four bytes in the width and height fields for similarity to MNG and PNG, and to leave room for future expansion, even though two bytes would have been sufficient.

When the color_type is 8 or 10 (no alpha channel), the last four bytes, which describe the IDAT data, must be set to zero. The IDAT_sample_depth must be nonzero when the alpha channel is present.

1.1.2. JDAT JNG image data

A JNG datastream must contain one or more JDAT chunks, whose data, when concatenated, forms a complete JNG baseline JPEG datastream.

A JNG baseline JPEG is a baseline JPEG as defined by JPEG Part 1 (ISO IS 10918-1), using only JFIF-compatible component interpretations, with a few additional restrictions that reflect limitations of many existing JPEG implementations.

JDAT chunks are like PNG IDAT chunks in that there may be multiple JDAT chunks, the data from which are concatenated to form a single datastream that can be sent to the decompressor. No chunks are permitted among the sequence of JDAT chunks, except for interleaved IDAT chunks. The ordering requirements of other ancillary chunks are the same with respect to JDAT as they are in PNG with respect to the IDAT chunk.

1.1.3. IDAT JNG alpha data

This chunk is exactly like the IDAT chunk in a PNG grayscale image, except that it is interpreted as an alpha mask to be applied to the image data from the JDAT chunks. The alpha channel, if present, can have sample depths 1, 2, 4, 8, or 16. The IDAT chunks can be interleaved with the JDAT chunks. No other chunk type can appear among the sequence of IDAT and JDAT chunks. No other chunk type can appear between the sequences of IDAT and JDAT chunks when they are not interleaved. The samples in the IDAT must be presented in noninterlaced order, left to right, top to bottom. As in PNG, zero means fully transparent and 2^IDAT_sample_depth-1 means fully opaque.

The IDAT chunks must precede the JSEP chunk, if the JSEP chunk is present. Minimal viewers that ignore the 12-bit JDAT chunks must read the 8-bit IDAT chunks and apply the alpha samples to the 8-bit image that is contained in the JDAT chunks that precede the JSEP chunk. Viewers that skip the 12-bit JDAT chunks must read the 8-bit IDAT chunks chunks that precede the JSEP chunk and apply the alpha samples to the 12-bit image that is contained in the JDAT chunks that follow the JSEP chunk. JDAT chunks must read the 8-bit IDAT chunks and apply the alpha samples to the 8-bit image that is contained in the JDAT chunks that precede the JSEP chunk.

1.1.4. IEND End of JNG datastream

The JNG IEND chunk is identical to its counterpart in PNG. Its data length is zero, and it serves to mark the end of the JNG datastream.

1.1.5. JSEP 8-bit/12-bit image separator

The JSEP chunk is empty.

A JSEP chunk must appear between the JDAT chunks of an 8-bit datastream and those of a 12-bit datastream, when JDAT_sample_depth=20 in the JHDR chunk. The 8-bit datastream must appear first. Both images must have the same width, height, color type, compression method, and interlace type. Viewers can choose to display one or the other image, but not both.

1.2. JNG ancillary chunks

Some PNG ancillary chunks can also appear in JNG datastreams, and are used for the same purposes as described in the PNG specification:

If the bKGD chunk is present, it must be written as if it were written for a PNG datastream with sample_depth=8. It has one 2-byte entry for grayscale JNGs and three 2-byte entries for color JNGs. The first (most significant) byte of each entry must be 0.

The following chunks have exactly the same meaning and have the same format as given in the PNG specification: cHRM, gAMA, iCCP, sRGB, pHYs, oFFs, tEXt, tIME, and zTXt.

The PNG PLTE, hIST, pCAL, sBIT, and tRNS chunks are not defined in JNG.

When cHRM, gAMA, iCCP, or sRGB are present, they provide information about the colorspace of the decoded JDAT image, and they have no effect on the decoded alpha samples from the IDAT chunks. Any viewer that processes the gAMA chunk must also recognize and process the sRGB chunk. It can treat it as if it were a gAMA chunk containing the value .45455 and it can ignore its "intent" field.

The chunk copying and ordering rules for JNG are the same as those in PNG, except for the fact that JDAT and IDAT chunks can be interleaved.

Author's Address

Glenn Randers-Pehrson
611 Rivershore Court
Edgewood, MD 21040-3603

Phone: (410) 278-6554

EMail: randeg @ alumni.rpi.edu
End of JNG Specification. This document expires on 11 May 1999