mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
Merge pull request #7570 from radarhere/gif_optimize
"optimize" default when saving GIF images
This commit is contained in:
commit
7070feccb7
|
@ -266,9 +266,12 @@ following options are available::
|
||||||
:py:class:`PIL.ImagePalette.ImagePalette` object.
|
:py:class:`PIL.ImagePalette.ImagePalette` object.
|
||||||
|
|
||||||
**optimize**
|
**optimize**
|
||||||
If present and true, attempt to compress the palette by
|
Whether to attempt to compress the palette by eliminating unused colors.
|
||||||
eliminating unused colors. This is only useful if the palette can
|
This is attempted by default, unless a palette is specified as an option or
|
||||||
be compressed to the next smaller power of 2 elements.
|
as part of the first image's :py:attr:`~PIL.Image.Image.info` dictionary.
|
||||||
|
|
||||||
|
This is only useful if the palette can be compressed to the next smaller
|
||||||
|
power of 2 elements.
|
||||||
|
|
||||||
Note that if the image you are saving comes from an existing GIF, it may have
|
Note that if the image you are saving comes from an existing GIF, it may have
|
||||||
the following properties in its :py:attr:`~PIL.Image.Image.info` dictionary.
|
the following properties in its :py:attr:`~PIL.Image.Image.info` dictionary.
|
||||||
|
|
|
@ -656,7 +656,7 @@ def _save(im, fp, filename, save_all=False):
|
||||||
palette = im.encoderinfo.get("palette", im.info.get("palette"))
|
palette = im.encoderinfo.get("palette", im.info.get("palette"))
|
||||||
else:
|
else:
|
||||||
palette = None
|
palette = None
|
||||||
im.encoderinfo["optimize"] = im.encoderinfo.get("optimize", True)
|
im.encoderinfo.setdefault("optimize", True)
|
||||||
|
|
||||||
if not save_all or not _write_multiple_frames(im, fp, palette):
|
if not save_all or not _write_multiple_frames(im, fp, palette):
|
||||||
_write_single_frame(im, fp, palette)
|
_write_single_frame(im, fp, palette)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user