| |
@@ -0,0 +1,45 @@
|
| |
+ From edf0b7412cd5cdf6e07f035d542c93033c374b37 Mon Sep 17 00:00:00 2001
|
| |
+ From: Thomas A Caswell <tcaswell@gmail.com>
|
| |
+ Date: Fri, 1 Apr 2022 11:46:32 -0400
|
| |
+ Subject: [PATCH] FIX: account for constant deprecations in Pillow 9.1
|
| |
+
|
| |
+ https://pillow.readthedocs.io/en/stable/deprecations.html#constants
|
| |
+ https://pillow.readthedocs.io/en/stable/releasenotes/9.1.0.html#constants
|
| |
+
|
| |
+ Image.None -> Image.Dither.None
|
| |
+ Image.ADAPTIVE -> Image.Palette.ADAPTIVE
|
| |
+
|
| |
+ (cherry picked from commit bb997708c08dae01ac95104f1f33d8c08c4715d4)
|
| |
+ ---
|
| |
+ lib/matplotlib/backends/backend_pdf.py | 15 +++++++++++++--
|
| |
+ 1 file changed, 13 insertions(+), 2 deletions(-)
|
| |
+
|
| |
+ diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py
|
| |
+ index 26a12764da..fa7d4a0075 100644
|
| |
+ --- a/lib/matplotlib/backends/backend_pdf.py
|
| |
+ +++ b/lib/matplotlib/backends/backend_pdf.py
|
| |
+ @@ -1646,8 +1646,19 @@ end"""
|
| |
+ # Convert to indexed color if there are 256 colors or fewer
|
| |
+ # This can significantly reduce the file size
|
| |
+ num_colors = len(img_colors)
|
| |
+ - img = img.convert(mode='P', dither=Image.NONE,
|
| |
+ - palette=Image.ADAPTIVE, colors=num_colors)
|
| |
+ + # These constants were converted to IntEnums and deprecated in
|
| |
+ + # Pillow 9.2
|
| |
+ + dither = (
|
| |
+ + Image.Dither.NONE if hasattr(Image, 'Dither')
|
| |
+ + else Image.NONE
|
| |
+ + )
|
| |
+ + pmode = (
|
| |
+ + Image.Palette.ADAPTIVE if hasattr(Image, 'Palette')
|
| |
+ + else Image.ADAPTIVE
|
| |
+ + )
|
| |
+ + img = img.convert(
|
| |
+ + mode='P', dither=dither, palette=pmode, colors=num_colors
|
| |
+ + )
|
| |
+ png_data, bit_depth, palette = self._writePng(img)
|
| |
+ if bit_depth is None or palette is None:
|
| |
+ raise RuntimeError("invalid PNG header")
|
| |
+ --
|
| |
+ 2.39.2
|
| |
+
|
| |
After a good bit of research, to get an EPEL 9 package of python-matplotlib I determined that we'll need to start with version 3.4.3 from the f34 branch. Before opening this PR I fast-forward merged f34 to epel9 to avoid this PR having 290+ commits. One additional changes was needed to get this to build, namely backporting an upstream commit to fix compatibility with Pillow 9.1. Once merged and built this will resolve rhbz#2041315. This won't be able to be built until rpms/python-pikepdf#6 is built and available.