blob: 32dfa11371b9e3ae9ff599a04e3f649d41ebab38 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2<html>
3<head>
4<!--
5Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
6DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7
8This code is free software; you can redistribute it and/or modify it
9under the terms of the GNU General Public License version 2 only, as
10published by the Free Software Foundation. Sun designates this
11particular file as subject to the "Classpath" exception as provided
12by Sun in the LICENSE file that accompanied this code.
13
14This code is distributed in the hope that it will be useful, but WITHOUT
15ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17version 2 for more details (a copy is included in the LICENSE file that
18accompanied this code).
19
20You should have received a copy of the GNU General Public License version
212 along with this work; if not, write to the Free Software Foundation,
22Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23
24Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
25CA 95054 USA or visit www.sun.com if you need additional information or
26have any questions.
27-->
28
29<title>GIF Metadata Format Specification</title>
30</head>
31
32<body bgcolor="white">
33
34<center><h1>
35GIF Metadata Format Specification
36</h1></center>
37
38<a name="gif_stream_metadata_format">
39<center><h2>
40GIF Stream Metadata Format Specification
41</h2></center>
42</a>
43<p>
44
45The GIF stream metadata format encodes the information stored in the
46per-file header, namely the file version, logical screen descriptor,
47and the global color table.
48
49<p>
50
51The logical screen descriptor describes the overall width and height
52of an animated file, as well as information about the color resolution
53(number of bits per pixel) and pixel aspect ratio.
54
55<p>
56
57The global color table contains a color lookup table that is used for
58images that do not have their own local color table.
59
60<pre>
61&lt;!DOCTYPE "javax_imageio_gif_stream_1.0" [
62
63 &lt;!ELEMENT "javax_imageio_gif_stream_1.0" (Version?,
64 LogicalScreenDescriptor?, GlobalColorTable?)&gt;
65
66 &lt;!ELEMENT "Version" EMPTY&gt;
67 &lt;!-- The file version, either 87a or 89a --&gt;
68 &lt;!ATTLIST "Version" "value" ("87a" | "89a") #REQUIRED&gt;
69 &lt;!-- The version string --&gt;
70
71 &lt;!ELEMENT "LogicalScreenDescriptor" EMPTY&gt;
72 &lt;!-- The logical screen descriptor, except for the global color table --&gt;
73 &lt;!ATTLIST "LogicalScreenDescriptor" "logicalScreenWidth" #CDATA
74 #REQUIRED&gt;
75 &lt;!-- The width in pixels of the whole picture --&gt;
76 &lt;!-- Data type: Integer --&gt;
77 &lt;!-- Min value: 1 (inclusive) --&gt;
78 &lt;!-- Max value: 65535 (inclusive) --&gt;
79 &lt;!ATTLIST "LogicalScreenDescriptor" "logicalScreenHeight" #CDATA
80 #REQUIRED&gt;
81 &lt;!-- The height in pixels of the whole picture --&gt;
82 &lt;!-- Data type: Integer --&gt;
83 &lt;!-- Min value: 1 (inclusive) --&gt;
84 &lt;!-- Max value: 65535 (inclusive) --&gt;
85 &lt;!ATTLIST "LogicalScreenDescriptor" "colorResolution" #CDATA
86 #REQUIRED&gt;
87 &lt;!-- The number of bits of color resolution, beteen 1 and 8 --&gt;
88 &lt;!-- Data type: Integer --&gt;
89 &lt;!-- Min value: 1 (inclusive) --&gt;
90 &lt;!-- Max value: 8 (inclusive) --&gt;
91 &lt;!ATTLIST "LogicalScreenDescriptor" "pixelAspectRatio" #CDATA
92 #REQUIRED&gt;
93 &lt;!-- If 0, indicates square pixels, else W/H = (value + 16)/64 --&gt;
94 &lt;!-- Data type: Integer --&gt;
95 &lt;!-- Min value: 0 (inclusive) --&gt;
96 &lt;!-- Max value: 255 (inclusive) --&gt;
97
98 &lt;!ELEMENT "GlobalColorTable" (ColorTableEntry)*&gt;
99 &lt;!-- The global color table --&gt;
100 &lt;!-- Min children: 2 --&gt;
101 &lt;!-- Max children: 256 --&gt;
102 &lt;!ATTLIST "GlobalColorTable" "sizeOfGlobalColorTable" ("2" |
103 "4" | "8" | "16" | "32" | "64" | "128" | "256") #REQUIRED&gt;
104 &lt;!-- The number of entries in the global color table --&gt;
105 &lt;!ATTLIST "GlobalColorTable" "backgroundColorIndex" #CDATA
106 #REQUIRED&gt;
107 &lt;!-- The index of the color table entry to be used as a background --&gt;
108 &lt;!-- Data type: Integer --&gt;
109 &lt;!-- Min value: 0 (inclusive) --&gt;
110 &lt;!-- Max value: 255 (inclusive) --&gt;
111 &lt;!ATTLIST "GlobalColorTable" "sortFlag" ("TRUE" | "FALSE")
112 #REQUIRED&gt;
113 &lt;!-- True if the global color table is sorted by frequency --&gt;
114
115 &lt;!ELEMENT "ColorTableEntry" EMPTY&gt;
116 &lt;!-- A global color table entry --&gt;
117 &lt;!ATTLIST "ColorTableEntry" "index" #CDATA #REQUIRED&gt;
118 &lt;!-- The index of the color table entry --&gt;
119 &lt;!-- Data type: Integer --&gt;
120 &lt;!-- Min value: 0 (inclusive) --&gt;
121 &lt;!-- Max value: 255 (inclusive) --&gt;
122 &lt;!ATTLIST "ColorTableEntry" "red" #CDATA #REQUIRED&gt;
123 &lt;!-- The red value for the color table entry --&gt;
124 &lt;!-- Data type: Integer --&gt;
125 &lt;!-- Min value: 0 (inclusive) --&gt;
126 &lt;!-- Max value: 255 (inclusive) --&gt;
127 &lt;!ATTLIST "ColorTableEntry" "green" #CDATA #REQUIRED&gt;
128 &lt;!-- The green value for the color table entry --&gt;
129 &lt;!-- Data type: Integer --&gt;
130 &lt;!-- Min value: 0 (inclusive) --&gt;
131 &lt;!-- Max value: 255 (inclusive) --&gt;
132 &lt;!ATTLIST "ColorTableEntry" "blue" #CDATA #REQUIRED&gt;
133 &lt;!-- The blue value for the color table entry --&gt;
134 &lt;!-- Data type: Integer --&gt;
135 &lt;!-- Min value: 0 (inclusive) --&gt;
136 &lt;!-- Max value: 255 (inclusive) --&gt;
137]&gt;
138</pre>
139<a name="gif_image_metadata_format">
140<center><h2>
141GIF Image Metadata Format Specification
142</h2></center>
143</a>
144<p>
145
146The GIF image metadata format encodes the image descriptor, local
147color table, and extension information assciated with a single image
148within a GIF file, typically a frame of an animation.
149
150<p>
151
152The image description contains the offset of the frame within the
153logical screen described in the stream metadata, as well as the width
154and height of the frame and whether it is used interlaced encoding.
155
156<p>
157
158The local color table, if present, supersedes the global color table
159for the frame at hand.
160
161<p>
162
163The graphic control extension contains information on how the frame is
164to be incorporated into the animation. The disposal method indicates
165whether the current frame should remain in place
166(<code>doNotDispose</code>), be restored to the backgound color as
167specified in the stream metadata
168(<code>restoreToBackgroundColor</code>), or be restored to the
169previous frame contents (<code>restoreToPrevious</code>) prior to
170displaying the subsequent frame.
171
172<p>
173
174The user input flag indicates whether the animation should pause for
175user input before advancing to the next frame. The transparent color
176flag and index indicate a color index for which pixels of the frame
177should not be drawn. The delay time indicates how long the frame
178should be displayed, in hundredths of a second. If the user input
179flag is set and the delay time is 0, the frame is intended to be
180advanced only on user input.
181
182<pre>
183&lt;!DOCTYPE "javax_imageio_gif_image_1.0" [
184
185 &lt;!ELEMENT "javax_imageio_gif_image_1.0" (ImageDescriptor?,
186 LocalColorTable?, GraphicControlExtension?, PlainTextExtension?,
187 ApplicationExtensions?, CommentExtensions?)&gt;
188
189 &lt;!ELEMENT "ImageDescriptor" EMPTY&gt;
190 &lt;!-- The image descriptor --&gt;
191 &lt;!ATTLIST "ImageDescriptor" "imageLeftPosition" #CDATA #REQUIRED&gt;
192 &lt;!-- The X offset of the image relative to the screen origin --&gt;
193 &lt;!-- Data type: Integer --&gt;
194 &lt;!-- Min value: 0 (inclusive) --&gt;
195 &lt;!-- Max value: 65535 (inclusive) --&gt;
196 &lt;!ATTLIST "ImageDescriptor" "imageTopPosition" #CDATA #REQUIRED&gt;
197 &lt;!-- The Y offset of the image relative to the screen origin --&gt;
198 &lt;!-- Data type: Integer --&gt;
199 &lt;!-- Min value: 0 (inclusive) --&gt;
200 &lt;!-- Max value: 65535 (inclusive) --&gt;
201 &lt;!ATTLIST "ImageDescriptor" "imageWidth" #CDATA #REQUIRED&gt;
202 &lt;!-- The width of the image --&gt;
203 &lt;!-- Data type: Integer --&gt;
204 &lt;!-- Min value: 1 (inclusive) --&gt;
205 &lt;!-- Max value: 65535 (inclusive) --&gt;
206 &lt;!ATTLIST "ImageDescriptor" "imageHeight" #CDATA #REQUIRED&gt;
207 &lt;!-- The height of the image --&gt;
208 &lt;!-- Data type: Integer --&gt;
209 &lt;!-- Min value: 1 (inclusive) --&gt;
210 &lt;!-- Max value: 65535 (inclusive) --&gt;
211 &lt;!ATTLIST "ImageDescriptor" "interlaceFlag" ("TRUE" | "FALSE")
212 #REQUIRED&gt;
213 &lt;!-- True if the image is stored using interlacing --&gt;
214
215 &lt;!ELEMENT "LocalColorTable" (ColorTableEntry)*&gt;
216 &lt;!-- The local color table --&gt;
217 &lt;!-- Min children: 2 --&gt;
218 &lt;!-- Max children: 256 --&gt;
219 &lt;!ATTLIST "LocalColorTable" "sizeOfLocalColorTable" ("2" |
220 "4" | "8" | "16" | "32" | "64" | "128" | "256") #REQUIRED&gt;
221 &lt;!-- The number of entries in the local color table --&gt;
222 &lt;!ATTLIST "LocalColorTable" "sortFlag" ("TRUE" | "FALSE")
223 #REQUIRED&gt;
224 &lt;!-- True if the local color table is sorted by frequency --&gt;
225
226 &lt;!ELEMENT "ColorTableEntry" EMPTY&gt;
227 &lt;!-- A local color table entry --&gt;
228 &lt;!ATTLIST "ColorTableEntry" "index" #CDATA #REQUIRED&gt;
229 &lt;!-- The index of the color table entry --&gt;
230 &lt;!-- Data type: Integer --&gt;
231 &lt;!-- Min value: 0 (inclusive) --&gt;
232 &lt;!-- Max value: 255 (inclusive) --&gt;
233 &lt;!ATTLIST "ColorTableEntry" "red" #CDATA #REQUIRED&gt;
234 &lt;!-- The red value for the color table entry --&gt;
235 &lt;!-- Data type: Integer --&gt;
236 &lt;!-- Min value: 0 (inclusive) --&gt;
237 &lt;!-- Max value: 255 (inclusive) --&gt;
238 &lt;!ATTLIST "ColorTableEntry" "green" #CDATA #REQUIRED&gt;
239 &lt;!-- The green value for the color table entry --&gt;
240 &lt;!-- Data type: Integer --&gt;
241 &lt;!-- Min value: 0 (inclusive) --&gt;
242 &lt;!-- Max value: 255 (inclusive) --&gt;
243 &lt;!ATTLIST "ColorTableEntry" "blue" #CDATA #REQUIRED&gt;
244 &lt;!-- The blue value for the color table entry --&gt;
245 &lt;!-- Data type: Integer --&gt;
246 &lt;!-- Min value: 0 (inclusive) --&gt;
247 &lt;!-- Max value: 255 (inclusive) --&gt;
248
249 &lt;!ELEMENT "GraphicControlExtension" EMPTY&gt;
250 &lt;!-- A graphic control extension --&gt;
251 &lt;!ATTLIST "GraphicControlExtension" "disposalMethod" ("none" |
252 "doNotDispose" | "restoreToBackgroundColor" |
253 "restoreToPrevious" | "undefinedDisposalMethod4" |
254 "undefinedDisposalMethod5" | "undefinedDisposalMethod6" |
255 "undefinedDisposalMethod7") #REQUIRED&gt;
256 &lt;!-- The disposal method for this frame --&gt;
257 &lt;!ATTLIST "GraphicControlExtension" "userInputFlag" ("TRUE" |
258 "FALSE") #REQUIRED&gt;
259 &lt;!-- True if the frame should be advanced based on user input --&gt;
260 &lt;!ATTLIST "GraphicControlExtension" "transparentColorFlag" (
261 "TRUE" | "FALSE") #REQUIRED&gt;
262 &lt;!-- True if a transparent color exists --&gt;
263 &lt;!ATTLIST "GraphicControlExtension" "delayTime" #CDATA #REQUIRED&gt;
264 &lt;!-- The time to delay between frames, in hundredths of a second --&gt;
265 &lt;!-- Data type: Integer --&gt;
266 &lt;!-- Min value: 0 (inclusive) --&gt;
267 &lt;!-- Max value: 65535 (inclusive) --&gt;
268 &lt;!ATTLIST "GraphicControlExtension" "transparentColorIndex"
269 #CDATA #REQUIRED&gt;
270 &lt;!-- The transparent color, if transparentColorFlag is true --&gt;
271 &lt;!-- Data type: Integer --&gt;
272 &lt;!-- Min value: 0 (inclusive) --&gt;
273 &lt;!-- Max value: 255 (inclusive) --&gt;
274
275 &lt;!ELEMENT "PlainTextExtension" EMPTY&gt;
276 &lt;!-- A plain text (text grid) extension --&gt;
277 &lt;!ATTLIST "PlainTextExtension" "textGridLeft" #CDATA #REQUIRED&gt;
278 &lt;!-- The X offset of the text grid --&gt;
279 &lt;!-- Data type: Integer --&gt;
280 &lt;!-- Min value: 0 (inclusive) --&gt;
281 &lt;!-- Max value: 65535 (inclusive) --&gt;
282 &lt;!ATTLIST "PlainTextExtension" "textGridTop" #CDATA #REQUIRED&gt;
283 &lt;!-- The Y offset of the text grid --&gt;
284 &lt;!-- Data type: Integer --&gt;
285 &lt;!-- Min value: 0 (inclusive) --&gt;
286 &lt;!-- Max value: 65535 (inclusive) --&gt;
287 &lt;!ATTLIST "PlainTextExtension" "textGridWidth" #CDATA #REQUIRED&gt;
288 &lt;!-- The number of columns in the text grid --&gt;
289 &lt;!-- Data type: Integer --&gt;
290 &lt;!-- Min value: 1 (inclusive) --&gt;
291 &lt;!-- Max value: 65535 (inclusive) --&gt;
292 &lt;!ATTLIST "PlainTextExtension" "textGridHeight" #CDATA #REQUIRED&gt;
293 &lt;!-- The number of rows in the text grid --&gt;
294 &lt;!-- Data type: Integer --&gt;
295 &lt;!-- Min value: 1 (inclusive) --&gt;
296 &lt;!-- Max value: 65535 (inclusive) --&gt;
297 &lt;!ATTLIST "PlainTextExtension" "characterCellWidth" #CDATA
298 #REQUIRED&gt;
299 &lt;!-- The width of a character cell --&gt;
300 &lt;!-- Data type: Integer --&gt;
301 &lt;!-- Min value: 1 (inclusive) --&gt;
302 &lt;!-- Max value: 65535 (inclusive) --&gt;
303 &lt;!ATTLIST "PlainTextExtension" "characterCellHeight" #CDATA
304 #REQUIRED&gt;
305 &lt;!-- The height of a character cell --&gt;
306 &lt;!-- Data type: Integer --&gt;
307 &lt;!-- Min value: 1 (inclusive) --&gt;
308 &lt;!-- Max value: 65535 (inclusive) --&gt;
309 &lt;!ATTLIST "PlainTextExtension" "textForegroundColor" #CDATA
310 #REQUIRED&gt;
311 &lt;!-- The text foreground color index --&gt;
312 &lt;!-- Data type: Integer --&gt;
313 &lt;!-- Min value: 0 (inclusive) --&gt;
314 &lt;!-- Max value: 255 (inclusive) --&gt;
315 &lt;!ATTLIST "PlainTextExtension" "textBackgroundColor" #CDATA
316 #REQUIRED&gt;
317 &lt;!-- The text background color index --&gt;
318 &lt;!-- Data type: Integer --&gt;
319 &lt;!-- Min value: 0 (inclusive) --&gt;
320 &lt;!-- Max value: 255 (inclusive) --&gt;
321
322 &lt;!ELEMENT "ApplicationExtensions" (ApplicationExtension)*&gt;
323 &lt;!-- A set of application extensions --&gt;
324 &lt;!-- Min children: 1 --&gt;
325 &lt;!-- Max children: 2147483647 --&gt;
326
327 &lt;!ELEMENT "ApplicationExtension" EMPTY&gt;
328 &lt;!-- An application extension --&gt;
329 &lt;!-- User object: array of byte --&gt;
330 &lt;!-- Min length: 0 --&gt;
331 &lt;!-- Max length: 2147483647 --&gt;
332 &lt;!ATTLIST "ApplicationExtension" "applicationID" #CDATA
333 #REQUIRED&gt;
334 &lt;!-- The application ID --&gt;
335 &lt;!-- Data type: String --&gt;
336 &lt;!ATTLIST "ApplicationExtension" "authenticationCode" #CDATA
337 #REQUIRED&gt;
338 &lt;!-- The authentication code --&gt;
339 &lt;!-- Data type: String --&gt;
340
341 &lt;!ELEMENT "CommentExtensions" (CommentExtension)*&gt;
342 &lt;!-- A set of comments --&gt;
343 &lt;!-- Min children: 1 --&gt;
344 &lt;!-- Max children: 2147483647 --&gt;
345
346 &lt;!ELEMENT "CommentExtension" EMPTY&gt;
347 &lt;!-- A comment --&gt;
348 &lt;!ATTLIST "CommentExtension" "value" #CDATA #REQUIRED&gt;
349 &lt;!-- The comment --&gt;
350 &lt;!-- Data type: String --&gt;
351]&gt;
352</pre>
353
354<p>
355<a name="mapping">
356<center>
357<table border=1>
358<caption><b>Mapping of Standard to GIF Native Stream Metadata</b></caption>
359<tr>
360<th>Standard Metadata Component</th>
361<th>GIF Native Stream Metadata Component</th>
362</tr>
363<tr>
364<td>/Chroma/Palette/PaletteEntry@index</td>
365<td>/GlobalColorTable/ColorTableEntry@index</td>
366</tr>
367<tr>
368<td>/Chroma/Palette/PaletteEntry@red</td>
369<td>/GlobalColorTable/ColorTableEntry@red</td>
370</tr>
371<tr>
372<td>/Chroma/Palette/PaletteEntry@green</td>
373<td>/GlobalColorTable/ColorTableEntry@green</td>
374</tr>
375<tr>
376<td>/Chroma/Palette/PaletteEntry@blue</td>
377<td>/GlobalColorTable/ColorTableEntry@blue</td>
378</tr>
379<tr>
380<td>/Chroma/BackgroundIndex@value</td>
381<td>/GlobalColorTable@backgroundColorIndex</td>
382</tr>
383<tr>
384<td>/Data/BitsPerSample@value</td>
385<td>/LogicalScreenDescriptor@colorResolution</td>
386</tr>
387<tr>
388<td>/Dimension/PixelAspectRatio@value</td>
389<td>/LogicalScreenDescriptor@pixelAspectRatio</td>
390</tr>
391<tr>
392<td>/Dimension/HorizontalScreenSize@value</td>
393<td>/LogicalScreenDescriptor@logicalScreenWidth</td>
394</tr>
395<tr>
396<td>/Dimension/VerticalScreenSize@value</td>
397<td>/LogicalScreenDescriptor@logicalScreenHeight</td>
398</tr>
399<tr>
400<td>/Document/FormatVersion@value</td>
401<td>/Version@value</td>
402</tr>
403</table>
404</center>
405</p>
406
407<p>
408<center>
409<table border=1>
410<caption><b>Mapping of Standard to GIF Native Image Metadata</b></caption>
411<tr>
412<th>Standard Metadata Component</th>
413<th>GIF Native Image Metadata Component</th>
414</tr>
415<tr>
416<td>/Chroma/Palette/PaletteEntry@index</td>
417<td>/LocalColorTable/ColorTableEntry@index</td>
418</tr>
419<tr>
420<td>/Chroma/Palette/PaletteEntry@red</td>
421<td>/LocalColorTable/ColorTableEntry@red</td>
422</tr>
423<tr>
424<td>/Chroma/Palette/PaletteEntry@green</td>
425<td>/LocalColorTable/ColorTableEntry@green</td>
426</tr>
427<tr>
428<td>/Chroma/Palette/PaletteEntry@blue</td>
429<td>/LocalColorTable/ColorTableEntry@blue</td>
430</tr>
431<tr>
432<td>/Dimension/HorizontalPixelOffset@value</td>
433<td>/ImageDescriptor@imageLeftPosition</td>
434</tr>
435<tr>
436<td>/Dimension/VerticalPixelOffset@value</td>
437<td>/ImageDescriptor@imageTopPosition</td>
438</tr>
439<tr>
440<td>/Text/TextEntry@value</td>
441<td>/CommentExtensions/CommentExtension@value</td>
442</tr>
443<tr>
444<td>/Transparency/TransparentIndex@value</td>
445<td>/GraphicControlExtension@transparentColorIndex
446(/GraphicControlExtension@transparentColorFlag is also set to
447"TRUE")</td>
448</tr>
449</table>
450</center>
451
452</body>
453</html>