forked from josch/img2pdf
set GifImagePlugin.LOADING_STRATEGY to RGB_AFTER_DIFFERENT_PALETTE_ONLY in Pillow >= 9.1.0 (closes: #130)
This commit is contained in:
parent
1d52530229
commit
d9345ac767
1 changed files with 11 additions and 1 deletions
|
@ -22,7 +22,17 @@ import sys
|
||||||
import os
|
import os
|
||||||
import zlib
|
import zlib
|
||||||
import argparse
|
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
|
# TiffImagePlugin.DEBUG = True
|
||||||
from PIL.ExifTags import TAGS
|
from PIL.ExifTags import TAGS
|
||||||
|
|
Loading…
Reference in a new issue