Skip to content
Snippets Groups Projects
Verified Commit 1eb048d2 authored by Yannick DAYER's avatar Yannick DAYER
Browse files

fix: adapt to PBM loading returning boolean values

Loading PBM files with imageio now returns an array of boolean.
This converts the image to uint8 with 0 or 255 values like before.
parent 2f84e019
No related branches found
No related tags found
No related merge requests found
Pipeline #87936 passed
......@@ -112,6 +112,10 @@ def open_file(filename) -> np.ndarray:
if img.shape[-1] == 1:
img = img.squeeze(-1)
# PBMs return a boolean array; Convert it to 0 or 255 values
if extension.lower() == ".pbm" and img.dtype == bool:
img = img.astype(np.uint8) * 255
img = check_gray(img)
return img if img.ndim == 2 else to_bob(img)
else:
......
......@@ -106,7 +106,7 @@ def test_netpbm():
transcode(datafile("test.pgm", __name__)) # indexed, works fine
transcode(datafile("test.ppm", __name__)) # indexed, works fine
transcode(datafile("test_2.pgm", __name__)) # indexed, works fine
# transcode(datafile("test_2.ppm", __name__)) # indexed, works fine ----> THIS DOES NOT WORK
transcode(datafile("test_2.ppm", __name__)) # indexed, works fine
transcode(datafile("test_spaces.pgm", __name__)) # indexed, works fine
# transcode(datafile("test.jpg", __name__)) # does not work
......@@ -153,6 +153,6 @@ def test_image_exceptions():
# Real GRAY PNG image
transcode(datafile("read_png_gray.png", __name__))
# Trucated JPEG
# Truncated JPEG
# THIS TEST FAILS
# transcode(datafile("truncated_jpeg.jpg", __name__))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment