Skip to content

Commit 9c184c1

Browse files
authored
Merge pull request matplotlib#30221 from neutrinoceros/bug/pillow13-compat
BUG: fix future incompatibility with Pillow 13
2 parents d797ee5 + 6ede069 commit 9c184c1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ def _recolor_icon(image, color):
775775
image_data = np.asarray(image).copy()
776776
black_mask = (image_data[..., :3] == 0).all(axis=-1)
777777
image_data[black_mask, :3] = color
778-
return Image.fromarray(image_data, mode="RGBA")
778+
return Image.fromarray(image_data)
779779

780780
# Use the high-resolution (48x48 px) icon if it exists and is needed
781781
with Image.open(path_large if (size > 24 and path_large.exists())

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,7 @@ def _writeImg(self, data, id, smask=None):
17841784
data[:, :, 2])
17851785
indices = np.argsort(palette24).astype(np.uint8)
17861786
rgb8 = indices[np.searchsorted(palette24, rgb24, sorter=indices)]
1787-
img = Image.fromarray(rgb8, mode='P')
1787+
img = Image.fromarray(rgb8).convert("P")
17881788
img.putpalette(palette)
17891789
png_data, bit_depth, palette = self._writePng(img)
17901790
if bit_depth is None or palette is None:

0 commit comments

Comments
 (0)