Remove paletted identical RGB channels from `eagle.png`
Context
The original file contained a RGB palette whose contents were identical. The image is therefore effectively grayscale. Previous to imageio v2.28, their pillow plugin had custom logic to check for this case in which case it would remove the duplicate channels. However, this behavior was removed in v2.28, which means that reading the image will return an array with those RGB channels as the last dimension which breaks scikit-image's existing API and tests. [1]
This PR removes the identical and superfluous channels. This is useful, regardless if imageio keeps the new behavior or not because it reduces the image size from 2.2 to 1.4 MiB.
I don't think we need to update the README.md for this change but let me know what you think.
[1] https://github.com/scikit-image/scikit-image/pull/6764#issuecomment-1502737516
Verify
You can verify that the image content stayed the same with the following code
import hashlib
import numpy as np
from imageio.v3 import imread
# from skimage.io import imread
def hash_arrays(arrays):
"""Hash the content of arrays."""
algorithm = hashlib.sha1()
for obj in arrays:
algorithm.update(obj)
return algorithm.hexdigest()
original = imread("https://gitlab.com/scikit-image/data/-/raw/2cdc5ce89b334d28f06a58c9f0ca21aa6992a5ba/eagle.png")
assert original.shape == (2019, 1826, 3)
updated = imread("https://gitlab.com/scikit-image/data/-/raw/46f32ca0fcc47706e9e4c85874b180b936b7293a/eagle.png")
assert updated.shape == (2019, 1826)
for i in range(3):
np.testing.assert_array_equal(original[..., i], updated)
orig_c = np.ascontiguousarray(original[..., i])
assert hash_arrays(orig_c) == hash_arrays(updated)