Skip to content

Commit b1dc8fc

Browse files
authored
Merge pull request #3283 from radarhere/gif
Improved GIF documentation
2 parents 9e6b625 + a91cb4b commit b1dc8fc

1 file changed

Lines changed: 45 additions & 19 deletions

File tree

docs/handbook/image-file-formats.rst

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@ The :py:meth:`~PIL.Image.Image.open` method sets the following
8484
of the GIF, in milliseconds.
8585

8686
**loop**
87-
May not be present. The number of times the GIF should loop.
87+
May not be present. The number of times the GIF should loop. 0 means that
88+
it will loop forever.
89+
90+
**comment**
91+
May not be present. A comment about the image.
92+
93+
**extension**
94+
May not be present. Contains application specific information.
8895

8996
Reading sequences
9097
~~~~~~~~~~~~~~~~~
@@ -115,25 +122,12 @@ are available::
115122
It is also supported for ICNS. If images are passed in of relevant sizes,
116123
they will be used instead of scaling down the main image.
117124

118-
**duration**
119-
The display duration of each frame of the multiframe gif, in
120-
milliseconds. Pass a single integer for a constant duration, or a
121-
list or tuple to set the duration for each frame separately.
122-
123-
**loop**
124-
Integer number of times the GIF should loop.
125-
126-
**optimize**
127-
If present and true, attempt to compress the palette by
128-
eliminating unused colors. This is only useful if the palette can
129-
be compressed to the next smaller power of 2 elements.
125+
**include_color_table**
126+
Whether or not to include local color table.
130127

131-
**palette**
132-
Use the specified palette for the saved image. The palette should
133-
be a bytes or bytearray object containing the palette entries in
134-
RGBRGB... form. It should be no more than 768 bytes. Alternately,
135-
the palette can be passed in as an
136-
:py:class:`PIL.ImagePalette.ImagePalette` object.
128+
**interlace**
129+
Whether or not the image is interlaced. By default, it is, unless the image
130+
is less than 16 pixels in width or height.
137131

138132
**disposal**
139133
Indicates the way in which the graphic is to be treated after being displayed.
@@ -146,6 +140,38 @@ are available::
146140
Pass a single integer for a constant disposal, or a list or tuple
147141
to set the disposal for each frame separately.
148142

143+
**palette**
144+
Use the specified palette for the saved image. The palette should
145+
be a bytes or bytearray object containing the palette entries in
146+
RGBRGB... form. It should be no more than 768 bytes. Alternately,
147+
the palette can be passed in as an
148+
:py:class:`PIL.ImagePalette.ImagePalette` object.
149+
150+
**optimize**
151+
If present and true, attempt to compress the palette by
152+
eliminating unused colors. This is only useful if the palette can
153+
be compressed to the next smaller power of 2 elements.
154+
155+
Note that if the image you are saving comes from an existing GIF, it may have
156+
the following properties in its :py:attr:`~PIL.Image.Image.info` dictionary.
157+
For these options, if you do not pass them in, they will default to
158+
their :py:attr:`~PIL.Image.Image.info` values.
159+
160+
**transparency**
161+
Transparency color index.
162+
163+
**duration**
164+
The display duration of each frame of the multiframe gif, in
165+
milliseconds. Pass a single integer for a constant duration, or a
166+
list or tuple to set the duration for each frame separately.
167+
168+
**loop**
169+
Integer number of times the GIF should loop. 0 means that it will loop
170+
forever. By default, the image will not loop.
171+
172+
**comment**
173+
A comment about the image.
174+
149175
Reading local images
150176
~~~~~~~~~~~~~~~~~~~~
151177

0 commit comments

Comments
 (0)