Skip to content

[io] Scale an image that Pillow reads in mode I to 8 bits like a 16-bit one - #2240

Open
RavSinghChandan wants to merge 1 commit into
mindee:mainfrom
RavSinghChandan:read-img-pillow-fallback
Open

RavSinghChandan wants to merge 1 commit into
mindee:mainfrom
RavSinghChandan:read-img-pillow-fallback

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

read_img_as_numpy decodes with OpenCV and used Pillow only for images with transparency, so an image OpenCV cannot decode raised "unable to read file." while read_img_as_tensor, which uses Pillow, read it. Of the 786 images in Pillow's own test images that Pillow opens (up to 20 megapixels), 95 failed in read_img_as_numpy; Pillow reads 55 of them (TGA, SGI, PSD, TIFF with LZMA compression or 12-bit and 16-bit samples, BMP and GIF files, and others). The other 40 are truncated or damaged files that Pillow cannot read either.

When OpenCV returns nothing, the image is now decoded with Pillow, the way the images with transparency are, and a file Pillow cannot read raises the same ValueError. Test added for TGA, SGI and PCX (formats OpenCV never decodes), from a path and from bytes, in RGB and BGR, with output_size, and a truncated file (fails on main).

…g_as_numpy

read_img_as_numpy decodes with OpenCV and used Pillow only for images with transparency, so an image that OpenCV cannot decode raised "unable to read file." while read_img_as_tensor, which uses Pillow, read it. Of the 786 images in Pillow's own test images that Pillow opens (up to 20 megapixels), 95 failed in read_img_as_numpy and Pillow reads 55 of them: TGA, SGI, PSD, TIFF with LZMA compression or with 12-bit and 16-bit samples, BMP and GIF files, among others. The other 40 are truncated or damaged files that Pillow cannot read either.

When OpenCV returns nothing the image is now decoded with Pillow, the way the images with transparency are, and a file that Pillow cannot read still raises the same ValueError.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant