tiff-java
                                
                                
                                
                                    tiff-java copied to clipboard
                            
                            
                            
                        LZW compression needs a max bit size of 12
Version Information:
- TIFF Java Version: 3.0.0
 
Expected Results:
Parse geo tiff images from https://geoint.nrlssc.org/nrltileserver/wcs without an exception The geotiff can be successfully read with java's ImageIO.read() as well as successfully opened in GIMP.
Observed Results:
Parsing the geotiff would often throw exceptions, sometimes about the byte stream ending early or other problems with the bytes. The happens on most geotiff downloads from that site
Output:
mil.nga.tiff.util.TiffException: No more remaining bytes to read. Total Bytes: 5707, Byte offset: 5704, Attempted to read: 4 at mil.nga.tiff.io.ByteReader.verifyRemainingBytes(ByteReader.java:415) at mil.nga.tiff.io.ByteReader.readFloat(ByteReader.java:364) at mil.nga.tiff.io.ByteReader.readFloat(ByteReader.java:351) at mil.nga.tiff.FileDirectory.readValue(FileDirectory.java:1353) at mil.nga.tiff.FileDirectory.readRaster(FileDirectory.java:1294) at mil.nga.tiff.FileDirectory.readRasters(FileDirectory.java:1220) at mil.nga.tiff.FileDirectory.readRasters(FileDirectory.java:1067) at mil.nga.tiff.FileDirectory.readRasters(FileDirectory.java:1019) at mil.nga.tiff.FileDirectory.readRasters(FileDirectory.java:998) at mil.nga.tiff.TiffReadTest.testLzw12BitMax(TiffReadTest.java:396)
Steps to Reproduce:
Download a geotiff from the nrlssc geoint tileserver. Example: https://geoint.nrlssc.org/nrltileserver/wcs/tlorigin?REQUEST=GetCoverage&VERSION=1.0.0&SERVICE=WCS&COVERAGE=USGS_NED_10m&FORMAT=GeoTIFF&BoundingBox=-117.55,33.41,-117.5,33.46&WIDTH=555&HEIGHT=555
TiffReader.readTiff( file ).getFileDirectory().readRasters();
An exception will probably be thrown about parsing the bytes.
Test Files:
https://geoint.nrlssc.org/nrltileserver/wcs/tlorigin?REQUEST=GetCoverage&VERSION=1.0.0&SERVICE=WCS&COVERAGE=USGS_NED_10m&FORMAT=GeoTIFF&BoundingBox=-117.55,33.41,-117.5,33.46&WIDTH=555&HEIGHT=555
Additional Information:
I have already tracked down the problem and I have a fix in hand including units tests. Comparing this implementation to java's native implementation I see that the number of bits is capped at 12. Adding that to the code allows the successful parsing of the tiff file.