Control: tags -1 + patch ftbfs
Control: unblock -1 by 1010595

The attached patch, based on an imageio upstream commit [1], fixes the
issue with Pillow 9.1 for me.


[1] https://github.com/imageio/imageio/pull/775
Description: handle PIL palettes with <256 colors
 based on https://github.com/imageio/imageio/pull/775
Bug-Debian: https://bugs.debian.org/1009431
Author: Graham Inggs <gin...@debian.org>
Last-Update: 2022-06-08

--- a/skimage/io/_plugins/pil_plugin.py
+++ b/skimage/io/_plugins/pil_plugin.py
@@ -160,7 +160,8 @@
     if pil_image.mode != 'P':
         raise ValueError('pil_image.mode must be equal to "P".')
     # get palette as an array with R, G, B columns
-    palette = np.asarray(pil_image.getpalette()).reshape((256, 3))
+    # Note: starting in pillow 9.1 palettes may have less than 256 entries
+    palette = np.asarray(pil_image.getpalette()).reshape((-1, 3))
     # Not all palette colors are used; unused colors have junk values.
     start, stop = pil_image.getextrema()
     valid_palette = palette[start:stop + 1]

Reply via email to