-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreadme.txt
457 lines (439 loc) · 13.5 KB
/
readme.txt
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
454
455
Help on module gif:
NAME
gif
DESCRIPTION
Byte-level GIF library.
The goal is to interface with the GIF format rather than edit the images,
therefore each class has generally public attributes and is intended to be
used as a struct. However, some quick functions are included due to the
relative efficiency.
Two command-line invocations are provided:
* gif.py test <file.gif>
This decompresses and recompresses the image to test the module.
* gif.py optimize <input.gif> <output.gif>
This compresses the image by removing extra colors and blocks.
CLASSES
builtins.RuntimeError(builtins.Exception)
GifFormatError
builtins.object
Gif
GifBlock
ExtensionBlock
ApplicationExtension
CommentExtension
GraphicExtension
PlainTextExtension
ImageBlock
class ApplicationExtension(ExtensionBlock)
| Initialize the application extension from the file
| This is probably deprecated.
|
| Method resolution order:
| ApplicationExtension
| ExtensionBlock
| GifBlock
| builtins.object
|
| Methods defined here:
|
| __init__(self)
| Initialize the block from its paramaters
|
| encode(self)
| Returns the bytes of the application extension block
|
| read(self, application, auth_code)
| Return the data only if the correct application and auth code are passed
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| decode(stream) from builtins.type
| Decode a new application extension from the given file
| Reads bytes from the already open file.
| Should happen after block header 0x21ff is found
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| application
| Get the application owning this extension
|
| auth_code
| Get the authentication code
|
| ----------------------------------------------------------------------
| Class methods inherited from GifBlock:
|
| deprecated() from builtins.type
| Check if this extension is deprecated
|
| version() from builtins.type
| Get the version required for this block
class CommentExtension(ExtensionBlock)
| Initialize the comment extension from the file
| There can be arbitrarily many of these in one GIF
| Don't use this because it's useless
|
| Method resolution order:
| CommentExtension
| ExtensionBlock
| GifBlock
| builtins.object
|
| Methods defined here:
|
| __init__(self, comment)
| Initialize extension with comment
|
| encode(self)
| Returns the bytes of the comment extension block
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| decode(stream) from builtins.type
| Reads bytes from the already open file.
| Should happen after block header 0x21fe is found
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| comment
| Get the comment text
|
| ----------------------------------------------------------------------
| Class methods inherited from GifBlock:
|
| deprecated() from builtins.type
| Check if this extension is deprecated
|
| version() from builtins.type
| Get the version required for this block
class ExtensionBlock(GifBlock)
| Base class for all GIF extension blocks
|
| Method resolution order:
| ExtensionBlock
| GifBlock
| builtins.object
|
| Class methods inherited from GifBlock:
|
| deprecated() from builtins.type
| Check if this extension is deprecated
|
| version() from builtins.type
| Get the version required for this block
class Gif(builtins.object)
| Opens the gif image
|
| Methods defined here:
|
| __init__(self, src=None)
| Opens the GIF image
|
| blocks_filter(self, block_cls)
| Get all blocks of the given class
|
| convert_gif87a(self)
| Convert the image to GIF87a format by discarding other blocks
|
| encode(self)
| Pack the entire GIF image
|
| optimize(self)
| Optimize the size of this image by removing extension blocks
| and resizing color tables.
|
| version(self)
| Get the GIF version
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| aspect_ratio
| Get the aspect ratio
|
| background
| Get the background color
|
| blocks
| Get the GIF blocks
|
| color_resolution
| Get the color resolution
|
| gct
| Get the GCT
|
| height
| Get the GIF height
|
| width
| Get the GIF width
class GifBlock(builtins.object)
| Base class for GIF blocks
|
| Class methods defined here:
|
| deprecated() from builtins.type
| Check if this extension is deprecated
|
| version() from builtins.type
| Get the version required for this block
class GifFormatError(builtins.RuntimeError)
| Raised when invalid format is encountered
|
| Method resolution order:
| GifFormatError
| builtins.RuntimeError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.RuntimeError:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __delattr__(self, name, /)
| Implement delattr(self, name).
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| helper for pickle
|
| __repr__(self, /)
| Return repr(self).
|
| __setattr__(self, name, value, /)
| Implement setattr(self, name, value).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class GraphicExtension(ExtensionBlock)
| Initialize the graphic extension block from the file
| There can only be one per image block, but there can be arbitrarily many
| within the entire GIF
|
| Method resolution order:
| GraphicExtension
| ExtensionBlock
| GifBlock
| builtins.object
|
| Methods defined here:
|
| __init__(self)
| Load the graphic extension block
|
| encode(self)
| Returns the bytes of the graphic extension block
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| decode(stream) from builtins.type
| Reads bytes from already open file.
| Should happen after block header 0x21f9 is discovered
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| delay
| Gets the actual delay time in milliseconds
|
| disposal
| Get the disposal method
|
| trans
| Get the index of transparency, or None if nontransparent
|
| user_input
| Check if the user input flag is set
|
| ----------------------------------------------------------------------
| Class methods inherited from GifBlock:
|
| deprecated() from builtins.type
| Check if this extension is deprecated
|
| version() from builtins.type
| Get the version required for this block
class ImageBlock(GifBlock)
| Initializes a GIF image block from the file
|
| Method resolution order:
| ImageBlock
| GifBlock
| builtins.object
|
| Methods defined here:
|
| __init__(self)
| Create a blank image block
|
| compress(self, indices)
| Replace the LZW data
|
| convert_to_gct(self, gct)
| Convert this image so it uses the gct
|
| convert_to_lct(self, gct)
| Convert this image and the LZW data to use a local color table
|
| decompress(self)
| Decodes the LZW data
|
| encode(self)
| Returns the bytes of the image block
| Ostensibly, should return its own input from the file
|
| update_gct(self, mapper)
| Make this image start using the new GCT
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| decode(stream, gct) from builtins.type
| Reads bytes from the already-open file.
| Should happen after block header 0x2c is discovered
| Requires to link with the main GIF gct, but can load without file
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| height
| Get the image height
|
| interlace
| Check if image is interlaced
|
| lct
| Get the local color table
|
| lzw
| Get the compressed LZW data
|
| position
| Get the image position
|
| width
| Get the image block width
|
| ----------------------------------------------------------------------
| Class methods inherited from GifBlock:
|
| deprecated() from builtins.type
| Check if this extension is deprecated
|
| version() from builtins.type
| Get the version required for this block
class PlainTextExtension(ExtensionBlock)
| Initialize the plain text extension from the file
| There can be arbitrarily many of these in one GIF
| This extension is probably deprecated
|
| Method resolution order:
| PlainTextExtension
| ExtensionBlock
| GifBlock
| builtins.object
|
| Methods defined here:
|
| __init__(self)
| Construct extension given properties
|
| encode(self)
| Returns the bytes of the plain text extension block
|
| insert_text(self, text, char_width, char_height)
| Set the text associated with this display
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| decode(stream) from builtins.type
| Reads bytes from the already open file.
| Should happen after block header 0x2101 is found
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| background
| Get the background color index
|
| cell
| Get the cell dimensions
|
| foreground
| Get the foreground color index
|
| grid
| Get the grid dimensions
|
| position
| Get the text position
|
| text
| Get the string being displayed
|
| ----------------------------------------------------------------------
| Class methods inherited from GifBlock:
|
| deprecated() from builtins.type
| Check if this extension is deprecated
|
| version() from builtins.type
| Get the version required for this block
DATA
GIF87a = '87a'
GIF89a = '89a'
__all__ = ['GIF87a', 'GIF89a', 'GifFormatError', 'GifBlock', 'Extensio...
FILE
gif\gif.py