File: rgba-in-gif-proposal-20070505 It is proposed to specify an RGBA extension to GIF, in case the PNG-in-GIF proposal fails to be approved. If PNG-in-GIF is approved, then this proposal will be abandoned. It is proposed to document the GIF extension in the Extensions to the PNG 1.2 Specification, Version 1.3.0, as follows: A. Change document version to 1.4.0. B. Add paragraph 6 and renumber subsequent paragraphs: 6. RGBA-in-GIF extension 6.1 Overview Section 6.3, below, is intended to be an extension to the GIF specification [GIF-SPEC]. It enhances GIF with the truecolor and alpha capabilities of PNG, while retaining the animation capabilities of GIF89a. Applications that do not recognize this RGBA extension or choose not to process it will fall back on a regular GIF animation or still image contained in the GIF file. 6.2 File Extension and MIME type Since a GIF with the RGBA extension chunk meets the GIF file syntax specification, authors can present them as "image/gif" and use the ".gif" extension. 6.3 RGBA Application Extension. a. Description. The RGBA Application Extension contains an LZW-compressed delta-RGBA image whose pixels may be added to those of the image in the GIF Image Descriptor (the "GIF Image") that it follows and displayed by a viewer in place of the unmodified GIF Image. The resulting RGBA image should be a higher quality version of the GIF Image and has an 8-bit alpha channel. 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 | | RGBA Image Identifier 8 Bytes +- -+ 4 | | +- -+ 5 | | +- -+ 6 | | +- -+ 7 | | +- -+ 8 | | +---------------+ 9 | | +- -+ 10 | | Authentication Code 3 Bytes +- -+ 11 | | +---------------+ +---------------+ 0 | | Header Block Size Byte +---------------+ 1 | | Image Width Unsigned +- -+ 2 | | +---------------+ 3 | | Image Height Unsigned +- -+ 4 | | +---------------+ +===============+ | | | | RGBA 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) RGBA Image Identifier - Sequence of eight printable ASCII characters used to identify the extension as a RGBA Application Extension. This must contain the ASCII characters "RGBAData" v) Authentication Code - Sequence of three bytes used to authenticate the RGBA Image Identifier. This must contain the decimal byte values 49, 46, 48 (ASCII "1.0"). vi) RGBA Image Data. Data Sub-blocks containing a complete RGBA image delta. The pixels must be RGBA, 8 bits per sample. The data is always compressed, using the "LZW" method. To obtain the value of the pixel for display, the decoder adds the value of each component (R,G,B, A) from the GIF Image to the corresponding component from the image delta. The addition is performed modulo 256. The GIF Image must be expanded to 8 bits if it has less than 8 bits, and the transparency bit must be expanded to 0 or 255, before adding the RGBA Image Data. The RGBA Image Data is never interlaced, whether the GIF Image data is interlaced or not. An empty RGBAData extension (without RGBA Image Data but with a Block Terminator byte) must precede the first GIF Image, to serve as a signal that an RGBAData extension will follow each GIF Image. [debatable: Other than simple modulo-256 addition, such as use of a bias value to improve compression] [debatable: Other than simple RGBARGBARGBA component order, such as planar or row-by-row interlacing] vii) Block Terminator. A zero length data sub-block that terminates the RGBA Image Data. This field contains the single byte value 0. d. Rendering the resulting 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 extensions such as ICCRGB01 and GAMMANOW) while doing this. This is described in more detail in ISO/IEC 15948:2003 e. The GIF Image may have colorspace information. Only one source of colorspace information may be used when presenting the RGBA Image, in the following order of priority: 1. GIF ICCRGB01 extension 2. GIF GAMMANOW extension (note that this contains the reciprocal of the PNG gamma value) 3. If no colorspace information is present, assume sRGB. f. Scope. 1. The preceding Image Descriptor, to which the RGBA pixel data is added, unless the extension is empty. 2. The following Image Descriptor, as a signal that another RGBAData extension will follow it. An empty RGBAData extension (without a header block or RGBA Image Data, but with a Block Terminator) must precede the first Image Descriptor for this purpose in any sequence of Image Descriptors having associated RGBAData extensions. g. Recommendation. The extension should follow an Image Descriptor. The image in the extension, after being added to the GIF Image, may be used in place of the the GIF Image and is displayed in the same way as the GIF Image. If a Graphics Control Extension appears before the GIF Image it applies to the RGBA Image as well. The transparent color information (flag and index) applies to the GIF Image, before adding the delta image to it. The resulting RGBA Image uses the resulting 8-bit alpha information. If an RGBA Application Extension does not follow a GIF Image, this is not an error, and the viewer must display the unmodified GIF Image. C. Add to the Appendix: Revision History * 1 June 2007 (version 1.4.0): * Added the RGBA-in-GIF Extensions. D. Add to the References [GIF-SPEC] "Graphics Interchange Format 89a" available at http://www.w3.org/Graphics/GIF/spec-gif89a.txt ---end of proposal---