set GifImagePlugin.LOADING_STRATEGY to RGB_AFTER_DIFFERENT_PALETTE_ONLY in Pillow >= 9.1.0 (closes: #130)

parent 1d52530229
commit d9345ac767
Signed by untrusted user: josch
GPG Key ID: F2CBA5C78FBD83E1

@ -22,7 +22,17 @@ import sys
import os
import zlib
import argparse
from PIL import Image, TiffImagePlugin
from PIL import Image, TiffImagePlugin, GifImagePlugin
if hasattr(GifImagePlugin, "LoadingStrategy"):
# Pillow 9.0.0 started emitting all frames but the first as RGB instead of
# P to make sure that more than 256 colors can be represented. But palette
# images compress far better than RGB images in PDF so we instruct Pillow
# to only emit RGB frames if the palette differs and return P otherwise.
# This works since Pillow 9.1.0.
GifImagePlugin.LOADING_STRATEGY = (
GifImagePlugin.LoadingStrategy.RGB_AFTER_DIFFERENT_PALETTE_ONLY
)
# TiffImagePlugin.DEBUG = True
from PIL.ExifTags import TAGS

Loading…
Cancel
Save