-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Can't create I;16S TIFF images #861
Comments
Pillow has supported some 16bit integer modes for a while. Currently there's support for unsigned int16, in little or bigendian mode. Some of that should patch cleanly, but the Access.c and Imaging.h won't. There's also a PyAccess.py version now to support cffi based pixel access method which would need some attention. I'm a concerned for the correctness of simply accessing and converting a signed int as a little endian unsigned int. That's likely to be wrong in some cases. |
I totally agree. I'd prefer a real solution to the workaround I posted. As things stand, I can't use MapProxy with 16 bit terrain data because the representation is signed. Both PIL and Pillow throw a ValueError exception when they encounter the I;16S mode. |
Are there samples of the 16bit terrain data online? |
Yes, a good one is GMTED, available from: http://earthexplorer.usgs.gov/. Available in 30, 15, and 7.5 arcsecond resolutions. You need to register with the USGS site to download. |
Same error with a 6001x6001 16-bit TIFF image from SRTM. What should I do ? |
What kind of image is it? Can I get a sample? |
Address: http://srtm.csi.cgiar.org/SRT-ZIP/SRTM_V41/SRTM_Data_GeoTiff/srtm_38_03.zip (36 MB zip) |
Bump! |
How to deal with
A simple workaround:
If set mode manually ( |
I am getting same error for Tiff file with Image mode "I" and 16BS type . How to deal with this error ? resp2 = req.get('tiff file url')
rawdata = resp2.content
im = Image.open(BytesIO(rawdata))
im Output
|
Hello? Is there any issue fixing this problem? I meet the same problem when merge USGS's TIF data to "RGB" |
@lixingang Hello! I'd expect there is some issue since this was opened in 2014 and still open … |
The SRTM URL no longer works. However, going to the base site and downloading http://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/tiff/srtm_14_02.zip, I find the the TIFF mode to now be I. |
#2748 is the reason for this. If I go back to 4.2.0, the files open as I;16S. So the problem from @s20208413 of reading I;16S images and trying to save them again should have been fixed by that issue. |
When trying to save a I;16S TIFF image, the user at the start of this issue attempted to create an I;16S image. They were hindered by the fact that I;16S is not one of our modes. I'm reluctant to add another mode, particularly because of #2228. However, if you create a I;16 image, it can be saved with a SAMPLEFORMAT tag of 2. from PIL import Image, TiffImagePlugin
im = Image.new("I;16", (100, 100))
im.save("i16s.tiff", tiffinfo={TiffImagePlugin.SAMPLEFORMAT: 2}) That will create an I;16S TIFF image. |
Moving to a more standard install of MapProxy, using Pillow. Pillow can load 16 bit grayscale TIFF images, but can't create them. Similar bug was in PIL. Steps to reproduce:
In the old PIL code, the changes below would fix the problem. I will need to look at the Pillow code to see if it is similar enough to make the same mods.
The text was updated successfully, but these errors were encountered: