Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bb99770

Browse filesBrowse files
committed
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
1 parent 20e38f4 commit bb99770
Copy full SHA for bb99770

File tree

Expand file treeCollapse file tree

1 file changed

+13
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-2
lines changed

‎lib/matplotlib/backends/backend_pdf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pdf.py
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,8 +1700,19 @@ def _writeImg(self, data, id, smask=None):
17001700
# Convert to indexed color if there are 256 colors or fewer
17011701
# This can significantly reduce the file size
17021702
num_colors = len(img_colors)
1703-
img = img.convert(mode='P', dither=Image.NONE,
1704-
palette=Image.ADAPTIVE, colors=num_colors)
1703+
# These constants were converted to IntEnums and deprecated in
1704+
# Pillow 9.2
1705+
dither = (
1706+
Image.Dither.NONE if hasattr(Image, 'Dither')
1707+
else Image.NONE
1708+
)
1709+
pmode = (
1710+
Image.Palette.ADAPTIVE if hasattr(Image, 'Palette')
1711+
else Image.ADAPTIVE
1712+
)
1713+
img = img.convert(
1714+
mode='P', dither=dither, palette=pmode, colors=num_colors
1715+
)
17051716
png_data, bit_depth, palette = self._writePng(img)
17061717
if bit_depth is None or palette is None:
17071718
raise RuntimeError("invalid PNG header")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.