Skip to content

Commit 0b2fa3f

Browse files
committed
BUG: fix future incompatibility with Pillow 13
1 parent 75c9b0a commit 0b2fa3f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,8 @@ 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)
1788+
img.convert("P")
17881789
img.putpalette(palette)
17891790
png_data, bit_depth, palette = self._writePng(img)
17901791
if bit_depth is None or palette is None:

0 commit comments

Comments
 (0)