File: jng-in-gif-proposal-20070428 It is proposed to specify a JNG extension to GIF, only if the PNG extension is approved. It is proposed to document the GIF extension in the MNG 1.0 Specification, as follows: A. Change document version to 1.0.1. B. Add section 14 and renumber subsequent sections: 14. JNG-in-GIF extension 14.1 Overview This is intended to be an extension to the GIF specification [GIF-SPEC]. It enhances GIF with the lossy compression, truecolor, and alpha capabilities of JNG, while retaining the animation capabilities of GIF89a, similar to the PNG-in-GIF extension described in the PNG Extensions document, version 1.4.0 or later. Applications that do not recognize this extension or choose not to process it will fall back on a regular GIF animation or still image contained in the GIF file. 14.2 File Extension and MIME type Since GIF files with the JNG extension chunk meet the GIF file syntax specification, authors can present them as "image/gif" and use the ".gif" extension. Authors who wish to distinguish clearly between static images and animations should use MIME type "video/x-gif" for animated GIFs. 14.3 JNG Application Extension. a. Description. The JNG Application Extension contains a JNG image that may be displayed by a viewer in place of the following Image Descriptor image. The JNG image should be a higher quality version of the Image Descriptor image. An encoder may use an empty or minimal placeholder for the Image Descriptor image. b. Required Version. 89a. c. Syntax. 7 6 5 4 3 2 1 0 Field Name Type +---------------+ 0 | | Extension Introducer Byte +---------------+ 1 | | Extension Label Byte +---------------+ +---------------+ 0 | | Block Size Byte +---------------+ 1 | | +- -+ 2 | | +- -+ 3 | | JNG Image Identifier 8 Bytes +- -+ 4 | | +- -+ 5 | | +- -+ 6 | | +- -+ 7 | | +- -+ 8 | | +---------------+ 9 | | +- -+ 10 | | Authentication Code 3 Bytes +- -+ 11 | | +---------------+ +---------------+ 0 | | Header Block Size Byte +---------------+ 1 | | Image Left Position Unsigned +- -+ 2 | | +---------------+ 3 | | Image Top Position Unsigned +- -+ 4 | | +---------------+ +===============+ | | | | JNG Image Data Data Sub-blocks | | | | +===============+ +---------------+ 0 | | Block Terminator Byte +---------------+ i) Extension Introducer - Defines this block as an extension. This field contains the fixed value 0x21. ii) Application Extension Label - Identifies the block as an Application Extension. This field contains the fixed value 0xFF. iii) Block Size - Number of bytes in this extension block, following the Block Size field, up to but not including the beginning of the Header Block Data. This field contains the fixed value 11. iv) JNG Image Identifier - Sequence of eight printable ASCII characters used to identify the extension as a JNG Application Extension. This must contain the ASCII characters "JNGImage" v) Authentication Code - Sequence of three bytes used to authenticate the JNG Image Identifier. This must contain the decimal byte values 49, 46, 50 (ASCII "1.2"). vi) Header block size - Number of bytes in the following header block, up to but not including the beginning of the JNG Image Data. This field contains the fixed value 4. vii) Image Left Position - Column number, in pixels, of the left edge of the image, with respect to the left edge of the Logical Screen. This is a two-byte unsigned integer in little-endian order. The leftmost column of the Logical Screen is 0. viii) Image Top Position - Row number, in pixels, of the top edge of the image with respect to the top edge of the Logical Screen. This is a two-byte unsigned integer in little-endian order. The top row of the Logical Screen is 0. The image width and height are obtained from the JNG JHDR chunk, in the JNG Image Data. Decoders must ignore any part of the image falling outside of the Logical Screen width and height, from the Logical Screen Descriptor. ix) JNG Image Data. Data Sub-blocks containing a complete JNG image, as defined by the MNG specification, except for the 8-byte JNG signature, which must be omitted. x) Block Terminator. A zero length data sub-block that terminates the JNG Image Data. This field contains the single byte value 0. d. Rendering the JNG Application Extension image must be performed by alpha composition of the image into the display. The alpha composition is expected to make the color components linear (using information from the relevant chunks such as gAMA, sRGB and iCCP) while doing this. This is described in more detail in ISO/IEC 15948:2003 e. Both the main GIF and the embedded JNG files may have colorspace information. Only one source of colorspace information may be used, in the following order of priority: 1. JNG sRGB chunk 2. JNG iCCP chunk 3. GIF ICCRGB01 extension 4. JNG gAMA and cHRM chunks 5. GIF GAMMANOW extension (note that this contains the reciprocal of the PNG gamma value) 6. If no colorspace information is present, assume sRGB. f. If the JNG Image Extension data contains a JDAT chunk immediately after the JHDR then a viewer must insert the contents of the preceding PNG Global Chunk Extension (if any) immediately after the JHDR. A decoder can detect this condition by processing bytes 28 through 35 (the 29th byte to the 36th) specially. These bytes contain a 4-byte length field and the 4-byte name of the first chunk after the JHDR chunk. If the last four of those bytes (bytes 29 to 32) contain ASCII 'JDAT' (decimal byte values 74, 68, 65, 84) or 'IDAT' (decimal byte values 73, 68, 65, 84) in that order the PNG Chunk Extension data must be inserted before the first of the length bytes (at position 28 in the JNG Image Extension image data stream.) If bytes 32 to 35 contain anything else, then the JNG Image contains its own ancillary chunks and the chunks in the PNG Global Chunk Extension are not used for that image. It is an error condition if the PNG Global Chunk Extension data contains chunks not permitted before JDAT or IDAT, including JDAT or IDAT itself. Decoders are not required to detect or handle this error condition; however, they must handle the error conditions that result if such data is inserted into a JNG Image Extension. Only one JNG Image Extension is permitted to precede any Image Descriptor, and if a JNG Image Extension is present, a PNG Image Extension is not permitted to precede that Image Descriptor. g. Extensions and Scope. This block does not have scope. This block can be modified only by the PNG Global Chunk Extension, which is described in the PNG Extensions document, version 1.4.0 or later. h. Recommendation. The extension should be followed by an Image Descriptor. The image in the extension may be used in place of the image in the Image Descriptor and is displayed in the same way as that image. If a Graphics Control Extension appears before the Image Descriptor it applies to the JNG Image regardless of whether it appears before or after the JNG image. The transparent color information (flag and index) applies only to the Image Descriptor, not the JNG Image, which has its own self-contained transparency/alpha information. If the JNG Application Extension is not followed by an Image Descriptor it must be ignored. C. Add to the Appendix: Revision History 15.1 Version 1.0.1 * 31 May 2007: * Added the JNG-in-GIF Extension. ---end of proposal---