aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html
blob: 57b9faa5eda1183c1183fe8124d614efa2adc2c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

This code is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 only, as
published by the Free Software Foundation.  Oracle designates this
particular file as subject to the "Classpath" exception as provided
by Oracle in the LICENSE file that accompanied this code.

This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
version 2 for more details (a copy is included in the LICENSE file that
accompanied this code).

You should have received a copy of the GNU General Public License version
2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
CA 95054 USA or visit www.sun.com if you need additional information or
have any questions.
-->

<title>GIF Metadata Format Specification</title>
</head>

<body bgcolor="white">

<center><h1>
GIF Metadata Format Specification
</h1></center>

<a name="gif_stream_metadata_format">
<center><h2>
GIF Stream Metadata Format Specification
</h2></center>
</a>
<p>

The GIF stream metadata format encodes the information stored in the
per-file header, namely the file version, logical screen descriptor,
and the global color table.

<p>

The logical screen descriptor describes the overall width and height
of an animated file, as well as information about the color resolution
(number of bits per pixel) and pixel aspect ratio.

<p>

The global color table contains a color lookup table that is used for
images that do not have their own local color table.

<pre>
&lt;!DOCTYPE "javax_imageio_gif_stream_1.0" [

  &lt;!ELEMENT "javax_imageio_gif_stream_1.0" (Version?, 
    LogicalScreenDescriptor?, GlobalColorTable?)&gt;

    &lt;!ELEMENT "Version" EMPTY&gt;
      &lt;!-- The file version, either 87a or 89a --&gt;
      &lt;!ATTLIST "Version" "value" ("87a" | "89a") #REQUIRED&gt;
        &lt;!-- The version string --&gt;

    &lt;!ELEMENT "LogicalScreenDescriptor" EMPTY&gt;
      &lt;!-- The logical screen descriptor, except for the global color table --&gt;
      &lt;!ATTLIST "LogicalScreenDescriptor" "logicalScreenWidth" #CDATA
         #REQUIRED&gt;
        &lt;!-- The width in pixels of the whole picture --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 1 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "LogicalScreenDescriptor" "logicalScreenHeight" #CDATA
         #REQUIRED&gt;
        &lt;!-- The height in pixels of the whole picture --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 1 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "LogicalScreenDescriptor" "colorResolution" #CDATA
         #REQUIRED&gt;
        &lt;!-- The number of bits of color resolution, beteen 1 and 8 --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 1 (inclusive) --&gt;
        &lt;!-- Max value: 8 (inclusive) --&gt;
      &lt;!ATTLIST "LogicalScreenDescriptor" "pixelAspectRatio" #CDATA
         #REQUIRED&gt;
        &lt;!-- If 0, indicates square pixels, else W/H = (value + 16)/64 --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 0 (inclusive) --&gt;
        &lt;!-- Max value: 255 (inclusive) --&gt;

    &lt;!ELEMENT "GlobalColorTable" (ColorTableEntry)*&gt;
      &lt;!-- The global color table --&gt;
      &lt;!-- Min children: 2 --&gt;
      &lt;!-- Max children: 256 --&gt;
      &lt;!ATTLIST "GlobalColorTable" "sizeOfGlobalColorTable" ("2" | 
        "4" | "8" | "16" | "32" | "64" | "128" | "256") #REQUIRED&gt;
        &lt;!-- The number of entries in the global color table --&gt;
      &lt;!ATTLIST "GlobalColorTable" "backgroundColorIndex" #CDATA
         #REQUIRED&gt;
        &lt;!-- The index of the color table entry to be used as a background --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 0 (inclusive) --&gt;
        &lt;!-- Max value: 255 (inclusive) --&gt;
      &lt;!ATTLIST "GlobalColorTable" "sortFlag" ("TRUE" | "FALSE")
         #REQUIRED&gt;
        &lt;!-- True if the global color table is sorted by frequency --&gt;

      &lt;!ELEMENT "ColorTableEntry" EMPTY&gt;
        &lt;!-- A global color table entry --&gt;
        &lt;!ATTLIST "ColorTableEntry" "index" #CDATA #REQUIRED&gt;
          &lt;!-- The index of the color table entry --&gt;
          &lt;!-- Data type: Integer --&gt;
          &lt;!-- Min value: 0 (inclusive) --&gt;
          &lt;!-- Max value: 255 (inclusive) --&gt;
        &lt;!ATTLIST "ColorTableEntry" "red" #CDATA #REQUIRED&gt;
          &lt;!-- The red value for the color table entry --&gt;
          &lt;!-- Data type: Integer --&gt;
          &lt;!-- Min value: 0 (inclusive) --&gt;
          &lt;!-- Max value: 255 (inclusive) --&gt;
        &lt;!ATTLIST "ColorTableEntry" "green" #CDATA #REQUIRED&gt;
          &lt;!-- The green value for the color table entry --&gt;
          &lt;!-- Data type: Integer --&gt;
          &lt;!-- Min value: 0 (inclusive) --&gt;
          &lt;!-- Max value: 255 (inclusive) --&gt;
        &lt;!ATTLIST "ColorTableEntry" "blue" #CDATA #REQUIRED&gt;
          &lt;!-- The blue value for the color table entry --&gt;
          &lt;!-- Data type: Integer --&gt;
          &lt;!-- Min value: 0 (inclusive) --&gt;
          &lt;!-- Max value: 255 (inclusive) --&gt;
]&gt;
</pre>
<a name="gif_image_metadata_format">
<center><h2>
GIF Image Metadata Format Specification
</h2></center>
</a>
<p>

The GIF image metadata format encodes the image descriptor, local
color table, and extension information assciated with a single image
within a GIF file, typically a frame of an animation.

<p>

The image description contains the offset of the frame within the
logical screen described in the stream metadata, as well as the width
and height of the frame and whether it is used interlaced encoding.

<p>

The local color table, if present, supersedes the global color table
for the frame at hand.

<p>

The graphic control extension contains information on how the frame is
to be incorporated into the animation.  The disposal method indicates
whether the current frame should remain in place
(<code>doNotDispose</code>), be restored to the backgound color as
specified in the stream metadata
(<code>restoreToBackgroundColor</code>), or be restored to the
previous frame contents (<code>restoreToPrevious</code>) prior to
displaying the subsequent frame.

<p>

The user input flag indicates whether the animation should pause for
user input before advancing to the next frame.  The transparent color
flag and index indicate a color index for which pixels of the frame
should not be drawn.  The delay time indicates how long the frame
should be displayed, in hundredths of a second.  If the user input
flag is set and the delay time is 0, the frame is intended to be
advanced only on user input.

<pre>
&lt;!DOCTYPE "javax_imageio_gif_image_1.0" [

  &lt;!ELEMENT "javax_imageio_gif_image_1.0" (ImageDescriptor?, 
    LocalColorTable?, GraphicControlExtension?, PlainTextExtension?, 
    ApplicationExtensions?, CommentExtensions?)&gt;

    &lt;!ELEMENT "ImageDescriptor" EMPTY&gt;
      &lt;!-- The image descriptor --&gt;
      &lt;!ATTLIST "ImageDescriptor" "imageLeftPosition" #CDATA #REQUIRED&gt;
        &lt;!-- The X offset of the image relative to the screen origin --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 0 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "ImageDescriptor" "imageTopPosition" #CDATA #REQUIRED&gt;
        &lt;!-- The Y offset of the image relative to the screen origin --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 0 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "ImageDescriptor" "imageWidth" #CDATA #REQUIRED&gt;
        &lt;!-- The width of the image --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 1 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "ImageDescriptor" "imageHeight" #CDATA #REQUIRED&gt;
        &lt;!-- The height of the image --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 1 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "ImageDescriptor" "interlaceFlag" ("TRUE" | "FALSE")
         #REQUIRED&gt;
        &lt;!-- True if the image is stored using interlacing --&gt;

    &lt;!ELEMENT "LocalColorTable" (ColorTableEntry)*&gt;
      &lt;!-- The local color table --&gt;
      &lt;!-- Min children: 2 --&gt;
      &lt;!-- Max children: 256 --&gt;
      &lt;!ATTLIST "LocalColorTable" "sizeOfLocalColorTable" ("2" | 
        "4" | "8" | "16" | "32" | "64" | "128" | "256") #REQUIRED&gt;
        &lt;!-- The number of entries in the local color table --&gt;
      &lt;!ATTLIST "LocalColorTable" "sortFlag" ("TRUE" | "FALSE")
         #REQUIRED&gt;
        &lt;!-- True if the local color table is sorted by frequency --&gt;

      &lt;!ELEMENT "ColorTableEntry" EMPTY&gt;
        &lt;!-- A local color table entry --&gt;
        &lt;!ATTLIST "ColorTableEntry" "index" #CDATA #REQUIRED&gt;
          &lt;!-- The index of the color table entry --&gt;
          &lt;!-- Data type: Integer --&gt;
          &lt;!-- Min value: 0 (inclusive) --&gt;
          &lt;!-- Max value: 255 (inclusive) --&gt;
        &lt;!ATTLIST "ColorTableEntry" "red" #CDATA #REQUIRED&gt;
          &lt;!-- The red value for the color table entry --&gt;
          &lt;!-- Data type: Integer --&gt;
          &lt;!-- Min value: 0 (inclusive) --&gt;
          &lt;!-- Max value: 255 (inclusive) --&gt;
        &lt;!ATTLIST "ColorTableEntry" "green" #CDATA #REQUIRED&gt;
          &lt;!-- The green value for the color table entry --&gt;
          &lt;!-- Data type: Integer --&gt;
          &lt;!-- Min value: 0 (inclusive) --&gt;
          &lt;!-- Max value: 255 (inclusive) --&gt;
        &lt;!ATTLIST "ColorTableEntry" "blue" #CDATA #REQUIRED&gt;
          &lt;!-- The blue value for the color table entry --&gt;
          &lt;!-- Data type: Integer --&gt;
          &lt;!-- Min value: 0 (inclusive) --&gt;
          &lt;!-- Max value: 255 (inclusive) --&gt;

    &lt;!ELEMENT "GraphicControlExtension" EMPTY&gt;
      &lt;!-- A graphic control extension --&gt;
      &lt;!ATTLIST "GraphicControlExtension" "disposalMethod" ("none" | 
        "doNotDispose" | "restoreToBackgroundColor" | 
        "restoreToPrevious" | "undefinedDisposalMethod4" | 
        "undefinedDisposalMethod5" | "undefinedDisposalMethod6" | 
        "undefinedDisposalMethod7") #REQUIRED&gt;
        &lt;!-- The disposal method for this frame --&gt;
      &lt;!ATTLIST "GraphicControlExtension" "userInputFlag" ("TRUE" | 
        "FALSE") #REQUIRED&gt;
        &lt;!-- True if the frame should be advanced based on user input --&gt;
      &lt;!ATTLIST "GraphicControlExtension" "transparentColorFlag" (
        "TRUE" | "FALSE") #REQUIRED&gt;
        &lt;!-- True if a transparent color exists --&gt;
      &lt;!ATTLIST "GraphicControlExtension" "delayTime" #CDATA #REQUIRED&gt;
        &lt;!-- The time to delay between frames, in hundredths of a second --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 0 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "GraphicControlExtension" "transparentColorIndex"
         #CDATA #REQUIRED&gt;
        &lt;!-- The transparent color, if transparentColorFlag is true --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 0 (inclusive) --&gt;
        &lt;!-- Max value: 255 (inclusive) --&gt;

    &lt;!ELEMENT "PlainTextExtension" EMPTY&gt;
      &lt;!-- A plain text (text grid) extension --&gt;
      &lt;!ATTLIST "PlainTextExtension" "textGridLeft" #CDATA #REQUIRED&gt;
        &lt;!-- The X offset of the text grid --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 0 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "PlainTextExtension" "textGridTop" #CDATA #REQUIRED&gt;
        &lt;!-- The Y offset of the text grid --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 0 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "PlainTextExtension" "textGridWidth" #CDATA #REQUIRED&gt;
        &lt;!-- The number of columns in the text grid --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 1 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "PlainTextExtension" "textGridHeight" #CDATA #REQUIRED&gt;
        &lt;!-- The number of rows in the text grid --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 1 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "PlainTextExtension" "characterCellWidth" #CDATA
         #REQUIRED&gt;
        &lt;!-- The width of a character cell --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 1 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "PlainTextExtension" "characterCellHeight" #CDATA
         #REQUIRED&gt;
        &lt;!-- The height of a character cell --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 1 (inclusive) --&gt;
        &lt;!-- Max value: 65535 (inclusive) --&gt;
      &lt;!ATTLIST "PlainTextExtension" "textForegroundColor" #CDATA
         #REQUIRED&gt;
        &lt;!-- The text foreground color index --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 0 (inclusive) --&gt;
        &lt;!-- Max value: 255 (inclusive) --&gt;
      &lt;!ATTLIST "PlainTextExtension" "textBackgroundColor" #CDATA
         #REQUIRED&gt;
        &lt;!-- The text background color index --&gt;
        &lt;!-- Data type: Integer --&gt;
        &lt;!-- Min value: 0 (inclusive) --&gt;
        &lt;!-- Max value: 255 (inclusive) --&gt;

    &lt;!ELEMENT "ApplicationExtensions" (ApplicationExtension)*&gt;
      &lt;!-- A set of application extensions --&gt;
      &lt;!-- Min children: 1 --&gt;
      &lt;!-- Max children: 2147483647 --&gt;

      &lt;!ELEMENT "ApplicationExtension" EMPTY&gt;
        &lt;!-- An application extension --&gt;
        &lt;!-- User object: array of byte --&gt;
        &lt;!-- Min length: 0 --&gt;
        &lt;!-- Max length: 2147483647 --&gt;
        &lt;!ATTLIST "ApplicationExtension" "applicationID" #CDATA
           #REQUIRED&gt;
          &lt;!-- The application ID --&gt;
          &lt;!-- Data type: String --&gt;
        &lt;!ATTLIST "ApplicationExtension" "authenticationCode" #CDATA
           #REQUIRED&gt;
          &lt;!-- The authentication code --&gt;
          &lt;!-- Data type: String --&gt;

    &lt;!ELEMENT "CommentExtensions" (CommentExtension)*&gt;
      &lt;!-- A set of comments --&gt;
      &lt;!-- Min children: 1 --&gt;
      &lt;!-- Max children: 2147483647 --&gt;

      &lt;!ELEMENT "CommentExtension" EMPTY&gt;
        &lt;!-- A comment --&gt;
        &lt;!ATTLIST "CommentExtension" "value" #CDATA #REQUIRED&gt;
          &lt;!-- The comment --&gt;
          &lt;!-- Data type: String --&gt;
]&gt;
</pre>

<p>
<a name="mapping">
<center>
<table border=1>
<caption><b>Mapping of Standard to GIF Native Stream Metadata</b></caption>
<tr>
<th>Standard Metadata Component</th>
<th>GIF Native Stream Metadata Component</th>
</tr>
<tr>
<td>/Chroma/Palette/PaletteEntry@index</td>
<td>/GlobalColorTable/ColorTableEntry@index</td>
</tr>
<tr>
<td>/Chroma/Palette/PaletteEntry@red</td>
<td>/GlobalColorTable/ColorTableEntry@red</td>
</tr>
<tr>
<td>/Chroma/Palette/PaletteEntry@green</td>
<td>/GlobalColorTable/ColorTableEntry@green</td>
</tr>
<tr>
<td>/Chroma/Palette/PaletteEntry@blue</td>
<td>/GlobalColorTable/ColorTableEntry@blue</td>
</tr>
<tr>
<td>/Chroma/BackgroundIndex@value</td>
<td>/GlobalColorTable@backgroundColorIndex</td>
</tr>
<tr>
<td>/Data/BitsPerSample@value</td>
<td>/LogicalScreenDescriptor@colorResolution</td>
</tr>
<tr>
<td>/Dimension/PixelAspectRatio@value</td>
<td>/LogicalScreenDescriptor@pixelAspectRatio</td>
</tr>
<tr>
<td>/Dimension/HorizontalScreenSize@value</td>
<td>/LogicalScreenDescriptor@logicalScreenWidth</td>
</tr>
<tr>
<td>/Dimension/VerticalScreenSize@value</td>
<td>/LogicalScreenDescriptor@logicalScreenHeight</td>
</tr>
<tr>
<td>/Document/FormatVersion@value</td>
<td>/Version@value</td>
</tr>
</table>
</center>
</p>

<p>
<center>
<table border=1>
<caption><b>Mapping of Standard to GIF Native Image Metadata</b></caption>
<tr>
<th>Standard Metadata Component</th>
<th>GIF Native Image Metadata Component</th>
</tr>
<tr>
<td>/Chroma/Palette/PaletteEntry@index</td>
<td>/LocalColorTable/ColorTableEntry@index</td>
</tr>
<tr>
<td>/Chroma/Palette/PaletteEntry@red</td>
<td>/LocalColorTable/ColorTableEntry@red</td>
</tr>
<tr>
<td>/Chroma/Palette/PaletteEntry@green</td>
<td>/LocalColorTable/ColorTableEntry@green</td>
</tr>
<tr>
<td>/Chroma/Palette/PaletteEntry@blue</td>
<td>/LocalColorTable/ColorTableEntry@blue</td>
</tr>
<tr>
<td>/Dimension/HorizontalPixelOffset@value</td>
<td>/ImageDescriptor@imageLeftPosition</td>
</tr>
<tr>
<td>/Dimension/VerticalPixelOffset@value</td>
<td>/ImageDescriptor@imageTopPosition</td>
</tr>
<tr>
<td>/Text/TextEntry@value</td>
<td>/CommentExtensions/CommentExtension@value</td>
</tr>
<tr>
<td>/Transparency/TransparentIndex@value</td>
<td>/GraphicControlExtension@transparentColorIndex
(/GraphicControlExtension@transparentColorFlag is also set to
"TRUE")</td>
</tr>
</table>
</center>

</body>
</html>