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