| 1 | From 9d8daba419249f9d3327fe85177d79b18adb6032 Mon Sep 17 00:00:00 2001
|
| 2 | From: Stefan van der Walt <[email protected]>
|
| 3 | Date: Thu, 8 Jan 2026 03:39:36 -0800
|
| 4 | Subject: [PATCH] Handle PIL Image.getdata deprecation (#8010)
|
| 5 |
|
| 6 | diff --git a/src/skimage/io/_plugins/pil_plugin.py b/src/skimage/io/_plugins/pil_plugin.py
|
| 7 | index 7a75c5fc0af..098d22a148e 100644
|
| 8 | |
| 9 | |
| 10 | @@ -47,6 +47,10 @@ def pil_to_ndarray(image, dtype=None, img_num=None):
|
| 11 | Refer to ``imread``.
|
| 12 |
|
| 13 | """
|
| 14 | + # PIL 12.1.0 renames getdata
|
| 15 | + if hasattr(image, "get_flattened_data"):
|
| 16 | + image.getdata = image.get_flattened_data
|
| 17 | +
|
| 18 | try:
|
| 19 | # this will raise an IOError if the file is not readable
|
| 20 | image.getdata()[0]
|