Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tifffile for .tiff support #62

Open
cr458 opened this issue Jan 27, 2021 · 3 comments
Open

tifffile for .tiff support #62

cr458 opened this issue Jan 27, 2021 · 3 comments

Comments

@cr458
Copy link

cr458 commented Jan 27, 2021

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.

@mseitzer
Copy link
Owner

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?

@cr458
Copy link
Author

cr458 commented Oct 11, 2021

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).

@mseitzer
Copy link
Owner

From python-pillow/Pillow#1888, it looks like you are correct. I will look into supporting multi-band float images then (probably using imageio).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants