tifffile for .tiff support
cr458 opened this issue · comments
PIL has some issues with reading TIF files as it automatically converts to uint8. What do you think about adding something like:
if path.suffix == ".tif":
img = tifffile.imread(path).astype(np.float32)
else:
img = Image.open(path).convert('RGB')
here. FWIW I've tested this modification locally and it's not a breaking change.
I would rather not add an additional dependency. It looks to me as if PIL supports TIF. Is it possible to avoid the conversion to uint8 by skipping .convert('RGB')
? What format do your images have?
I think there's only support for single-band floating point image formats in PIL
. My images are multi-band floating point images (remote sensing imagery).
From python-pillow/Pillow#1888, it looks like you are correct. I will look into supporting multi-band float images then (probably using imageio
).