File: rgba-in-gif-proposal-20070503

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 a
      deflate-compressed RGBA image that may be displayed by a viewer in
      place of the following Image Descriptor image.  The RGBA 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  |               |       RGBA Image Identifier      8 Bytes
          +-             -+
       4  |               |
          +-             -+
       5  |               |
          +-             -+
       6  |               |
          +-             -+
       7  |               |
          +-             -+
       8  |               |
          +---------------+
       9  |               |
          +-             -+
      10  |               |       Authentication Code        3 Bytes
          +-             -+
      11  |               |
          +---------------+
      
          +===============+
          |               |
          |               |       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 PNG Application
      Extension.  This must contain the ASCII characters "RGBAData"
      
      v) Authentication Code - Sequence of three bytes used to
      authenticate the PNG 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, as defined as the contents of a sequence of PNG IDAT chunks
      by the PNG specification, ISO/IEC 15948:2003.  The image must be
      RGBA, 8 bits per sample.  The image width and height are obtained
      from the GIF Logical Image Descriptor.  Decoders must ignore any
      part of the image falling outside of the Logical Screen width and
      height, from the Logical Screen Descriptor.  A PNG filter byte must
      precede each scanline, to be interpreted according to the PNG
      specification.  It can be interlaced or not, depending on whether
      the main GIF image is interlaced.  The data is always compressed,
      as in PNG, using the "deflate" method.
      
      vii) Block Terminator.  A zero length data sub-block that terminates
      the PNG Image Data.  This field contains the single byte value 0.
      
      d. Rendering the RGBA 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 extensions such as ICCRGB01 and GAMMANOW) while doing
      this.  This is described in more detail in ISO/IEC 15948:2003
      
      e. The main GIF may have colorspace information.  Only one source
      of colorspace information may be used, 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. Extensions and Scope. This block does not have scope.
      
      g. 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 RGBA Image regardless of whether it appears
      before or after the RGBA image.  The transparent color information
      (flag and index) applies only to the Image Descriptor, not the RGBA
      Image, which has its own self-contained alpha information.
      If the RGBA Application Extension is not followed by an Image Descriptor
      it must be ignored.

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---