File Pillow-13-compat.patch of Package python-matplotlib

From 0b2fa3f952b6b97a121a3d7f05a0753b52b802cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= <cr52@protonmail.com>
Date: Sat, 28 Jun 2025 11:39:49 +0200
Subject: [PATCH] BUG: fix future incompatibility with Pillow 13

---
 lib/matplotlib/backends/_backend_tk.py | 2 +-
 lib/matplotlib/backends/backend_pdf.py | 2 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py
index 0bbff1379ffa..eaf868fd8bec 100644
--- a/lib/matplotlib/backends/_backend_tk.py
+++ b/lib/matplotlib/backends/_backend_tk.py
@@ -775,7 +775,7 @@ def _recolor_icon(image, color):
             image_data = np.asarray(image).copy()
             black_mask = (image_data[..., :3] == 0).all(axis=-1)
             image_data[black_mask, :3] = color
-            return Image.fromarray(image_data, mode="RGBA")
+            return Image.fromarray(image_data)
 
         # Use the high-resolution (48x48 px) icon if it exists and is needed
         with Image.open(path_large if (size > 24 and path_large.exists())
diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py
index f20bdffd4a3a..4429dc9ba707 100644
--- a/lib/matplotlib/backends/backend_pdf.py
+++ b/lib/matplotlib/backends/backend_pdf.py
@@ -1784,7 +1784,7 @@ def _writeImg(self, data, id, smask=None):
                          data[:, :, 2])
                 indices = np.argsort(palette24).astype(np.uint8)
                 rgb8 = indices[np.searchsorted(palette24, rgb24, sorter=indices)]
-                img = Image.fromarray(rgb8, mode='P')
+                img = Image.fromarray(rgb8).convert("P")
                 img.putpalette(palette)
                 png_data, bit_depth, palette = self._writePng(img)
                 if bit_depth is None or palette is None:
openSUSE Build Service is sponsored by