WhyWaitForever

London England

VisibleGif - XML Tags Guide

This page describes the XML tags used in the XML file that is produced by VisibleGif to represent the input GIF format image file. The XML tagged text file that can be produced by VisibleGif from an existing GIF file. It can be created from new using any text editor software.

The XML file can be used to create a new GIF image file. VisibleGif generates the GIF trailer block at the end of a GIF file.

Blocks

  • A GIF format image file comprises a stream of bytes.

  • These bytes are organised as a series of blocks of bytes.

  • The XML tag names for the various blocks are as listed.

  • The blocks are described below.

  • header
  • global-color-table
  • application
  • graphics
  • image
  • text
  • comment

Block Precedence

  • The first block must be the "header" block.

  • If a "global-color-table" block is present is must immediately follow the "header" block.

  • The other blocks can be combined in any order.

  • It is usual to place the "comment" block if present at the end.


Block Usage

  • An "application" block is used in GIF animations.

  • A "graphic" block contains image related information. It can be present in both GIF animations and in single images.

  • An "image" block contains the image information. It can have an associated "local-colour-table".

  • A "text" block contains text data for rendering onto the image. This block is little used as fonts are usually stored as part of the main image.

  • A "comment" block contains text for use by image editing programs and is not used in rendering an image onto display or print media.


Minimum Blocks

For a Single Image

A single image can comprise the following minimum number of blocks. The image contains a "local-colour-table".

  1. header
  2. image

If the single image used a transparent background colour it could be implemented in the following minimum number of blocks.

  1. header
  2. graphic
  3. image

For an Animation

Assume the animation contained two images.

  1. header
  2. global-colour-table
  3. graphic
  4. image
  5. graphic
  6. image

XML Header and Trailer Tags

At the start and end of each XML file are some tags that contain reference information. They contain the start and end times of processing. They list the file that was used as input. These are ignored by VisibleGif.

Header Tags


<?xml version="1.0"?>
<gif>

  <start-time>6 Jan 2000 14:11:49 GMT</start-time>

  <file>c:\visibleg\xml\gicon.gif</file>


Trailer Tags


  <end-time>6 Jan 2000 14:11:51 GMT</end-time>

</gif>



Header Block Tags


 <header>
   <signature>GIF</signature>
   <version>89a</version>
   <screen>
     <width>60</width>
     <height>70</height>
   </screen>
   <global-color-table-present>true</global-color-table-present>
   <colors-sorted-by-importance>false</colors-sorted-by-importance>
   <color-resolution>8</color-resolution>
   <global-color-table-size>4</global-color-table-size>
   <background-color-index>0</background-color-index>
   <pixel-aspect-ratio>0</pixel-aspect-ratio>
 </header>


signature
This is a literal and should always be "GIF" in uppercase.
version
This must be either the literal "89a" or "87a". The case is significant.

The older version "87a" only processes the "header" block and the "image" block.

screen
This is an information tag which is not used in processing. By convention the display area (which is unlikely to be the whole screen) is called the screen. It defines a "canvas" within the screen area onto which the image or images are rendered.

A display area (screen) could be set to be 100 pixels wide and 100 pixels high. An image could be set to be 50 pixels wide and 100 pixels high with zero offset from top and left. The image will cover the left hand side of the display area. The pixels not covered by the image will have the background-colour-index colour from this header block.

width
This is the width of the display area (screen) in pixels.
height
This is the height of the display area (screen) in pixels.
global-color-table-present
This is either "true" or "false". If a global colour table is not present a local colour table should be present associated with each image.
colors-sorted-by-importance
This is either "true" or "false". The colour tables can be sorted in most used colours first. This was designed to speed up the processing of some display software. It does not appear to be implemented by most of the common display software and so will usually be set to "false".
colour-resolution
This is the number of bits per primary colour. It can range from "1" to "8". It usually is set to "8".
global-color-table-size
This is the number of entries in the global colour table and so is the same as the number of colours that can be used. There should be at least 1 entry for each colour used.
background-color-index
This is the entry for the colour in the global colour table that will be used for pixels in the display area (as defined by screen width and height) that are not covered by the images (as defined by top, left, width and height for each image).
pixel-aspect-ratio
This is usually set to be "0". This field allows the ratio of pixel width to height to be changed.

Global Colour Table Block Tags


 <global-color-table>
  <red>ff</red>  <green>ff</green>  <blue>ff</blue>
  <red>ff</red>  <green>99</green>  <blue>33</blue>
  <red>66</red>  <green>33</green>  <blue>00</blue>
  <red>00</red>  <green>00</green>  <blue>00</blue>
 </global-color-table>


red
The two hex characters that represents the red element of the colour.
green
The two hex characters that represents the green element of the colour.
blue
The two hex characters that represents the blue element of the colour.

Application Block Tags


 <application>
  <blocksize>11</blocksize>
  <identifier>NETSCAPE</identifier>
  <authentication-code>2.0</authentication-code>
  <data>
   <blocksize>3</blocksize>
   <bytes>010000</bytes>
   <blocksize>0</blocksize>
   <bytes></bytes>
  </data>
 </application>


blocksize
The length of the application block which is a fixed size "11".
identifier
This is a literal and should always be "NETSCAPE" in uppercase.
authentication-code
This is a literal and should always be "2.0".
data
This is processing control tag and must be present. It indicates that blocks of data follows.
blocksize
The length of the following group of bytes.
bytes
The bytes with two hex characters for each byte.

If the blocksize is "3" the data block is the "looping" extension. In this case the next byte is "01" hex and the following 2 bytes values "0000" hex to "FFFF" hex represents the loop count. "0000" means that the animation should loop forever.

If the blocksize is "5" the data block is the "buffering" extension. In this case the next byte is "01" hex and the next four bytes values "00000000" hex to "FFFFFFFF" hex is the buffering size. This is the number of bytes to enter the display software buffer before the graphics rendering process should start. Any delay time in the graphics block is calculated as starting after the buffer delay.


Graphic Block Tags


 <graphic>
  <blocksize>4</blocksize>
  <disposal-method>2 Restore to background color</disposal-method>
  <user-input>false</user-input>
  <transparent-color-index-present>true</transparent-color-index-present>
  <delay-time>30</delay-time>
  <transparent-color-index>03</transparent-color-index>
 </graphic>


blocksize
The length of the graphic block which is usually "4".
disposal-method
This describes how the image is to be treated after it has been displayed.
  • 0 - No disposal specified
  • 1 - Do not dispose. Leave the image in place
  • 2 - Restore to background colour.
  • 3 - Restore to the previous image.
user-input
This is either "true" or "false". If "true" this indicates that the display software should wait for user input or the delay time which ever comes first. This is usually "false".
transparent-color-index-present
This is either "true" or "false". If "true" transparent-color-index processing should be undertaken.
delay-time
The delay time before displaying the images in hundredths of a second. It is appropriate in GIF animations.
transparent-color-index
If transparent-color-index-present is "true" and this colour index is found in the image the corresponding pixel in the display is not modified.

Image Block Tags


 <image>
  <left>0</left>
  <top>0</top>
  <width>60</width>
  <height>70</height>
  <local-color-table-present>false</local-color-table-present>
  <interlaced>false</interlaced>
  <colors-sorted-by-importance>false</colors-sorted-by-importance>
  <local-color-table-size>4</local-color-table-size>

  <local-color-table>
    <red>ff</red>  <green>ff</green>  <blue>ff</blue>
    <red>ff</red>  <green>99</green>  <blue>33</blue>
    <red>66</red>  <green>33</green>  <blue>00</blue>
    <red>00</red>  <green>00</green>  <blue>00</blue>
  </local-color-table>

  <lzw-minimum-code-size>2</lzw-minimum-code-size>
  <data-packed>

   <blocksize>255</blocksize>
   <bytes>9c8fa9cbedef848450d0bba4c548f37f78980896c3 .. f288a</bytes>
   <blocksize>102</blocksize>
   <bytes>d9323684d2f1cac78bd63c5a045952e43c8e291946 .. 90a00</bytes>
   <blocksize>0</blocksize>
   <bytes></bytes>
  </data-packed>

  <data-codes>
   <code size="3" >4</code> <code size="3" >3</code>
   <code size="3" >6</code> <code size="3" >7</code>
   <code size="4" >8</code> <code size="4" >9</code>
   .....
  </data-codes>

  <used-colours>
   <rgb>FFFFFF</rgb> <offset>3</offset> <edit>D</edit> <count>2148</count>
   <rgb>FF9933</rgb> <offset>2</offset> <edit>C</edit> <count>347</count>
   <rgb>663300</rgb> <offset>1</offset> <edit>B</edit> <count>166</count>
   <rgb>000000</rgb> <offset>0</offset> <edit>A</edit> <count>1539</count>
  </used-colours>

<data-rows>
<row count="0">DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD .. D</row>
<row count="1">DDDDDDDDDDDDDDDDDDCCCDDDDDDDDDDDDDDDDDDDDCCCDDDDDDD .. D</row>
.....
</data-rows> 

 </image>


left
This is the offset in pixels from the left of the display area (screen) set in the header block.
top
This is the offset in pixels from the top of the display area (screen) set in the header block.
width
This is the width of the image in pixels.
height
This is the height of the image in pixels.
local-color-table-present
This is either "true" or "false". This indicates whether a local colour table is associated with the image.
interlaced
This is either "true" or "false". This indicates to the display program whether the image is interlaced in a four pass pattern.
colors-sorted-by-importance
This is either "true" or "false". The colour table can be sorted in most used colours first. This was designed to speed up the processing of some display software. It does not appear to be implemented by most of the common display software and so will usually be set to "false".
local-color-table-size
This is the number of entries in the local colour table and so is the same as the number of colours that can be used in this image. There should be at least 1 entry for each colour used. If a local colour table is not present this is set to "0".
lzw-minimum-code-size
This is one less than the size in bits of storage needed to hold the initial set of compression codes. The initial set of compression codes are all the colours in the table plus two codes (the "clear" code and the "end of information" code).

The smallest value is "1" (the code size is 2 bits with a maximum code value of 3). The largest value of this code is "11" (the code size is 12 bits with a maximum code value of 4095).

lzw-minimum-code-sizeMaximum coloursMaximum code value
123
267
31415
43031
56263
6126127
7254255
8256511
92561023
102562047
112564095

The maximum number of colours in a single colour table is set at 256 (codes 0 to 255). This cannot be exceeded.

data-packed
This is processing control tag and must be present. It indicates that blocks of data follows.
blocksize
The length of the following group of bytes.
bytes
The bytes with two hex characters for each byte. The bits are packed.
data-codes
This tag groups the compression codes.
code
This is the current compression code together with the size in bits. The codes are unpacked.
used-colors
This tag groups the tags used for the details of the used colours.
rgb
This is the rgb colour where the first to hex codes represent red, the next two represent green and the last two represent blue.
offset
The index into the colour table
edit
This is the editable character code used in the "row" representation.
count
This is the count of usage of the colour
data-rows
This tag groups the editable rows.
row
The attribute count the the row count. The image is represented as a series of editable characters using the edit characters listed in the the used-colors table.

Text Block Tags

This block is rarely used. Text characters in a particular font are created as additional images which are overlayed on other images with the background colour set as a transparent colour.


 <text>
  <blocksize>12</blocksize>
  <left>0</left>
  <top>0</top>
  <width>60</width>
  <height>70</height>
  <cell-width>60</cell-width>
  <cell-height>70</cell-height>
  <data-packed>
   <blocksize>3</blocksize>
   <bytes>010000</bytes>
   <blocksize>0</blocksize>
   <bytes></bytes>
  </data-packed>
 </text>


blocksize
The length of the text block which is of fixed size "12".
left
This is the offset in pixels from the left of the display area (screen) set in the header block.
top
This is the offset in pixels from the top of the display area (screen) set in the header block.
width
This is the width of the text block in pixels.
height
This is the height of the text block in pixels.
cell-width
This is the width of each character cell in pixels.
cell-height
This is the height of each character cell in pixels.
foreground-color-index
The colour to be used for the character.
background-color-index
The colour to be used for the background. This can be transparent.
data-packed
This is processing control tag and must be present. It indicates that blocks of data follows.
blocksize
The length of the following group of bytes.
bytes
The bytes with two hex characters for each byte.

Comment Block Tags


 <comment>
  <blocksize>47</blocksize>
  <message>Generated by bloat image software on 13/11/1999</message>
 </comment>


blocksize
The length of the text that needs to be included.
message
The text that needs to be included.
Life's too short why wait forever
Privacy Declaration
Copyright © 2000 - 2005. WhyWaitForever. All rights reserved.
Legal Disclaimer