public static int readOrientationFromTIFF ( InputStream is , int length ) throws IOException { // read tiff header TiffHeader tiffHeader = new TiffHeader ( ) ; length = readTiffHeader ( is , length , tiffHeader ) ; // move to the first IFD // offset is relative to the beginning of the TIFF data // and we already consumed the first 8 bytes of header int toSkip = tiffHeader . firstIfdOffset - 8 ; if ( length == 0 || toSkip > length ) { return 0 ; } is . skip ( toSkip ) ; length -= toSkip ; // move to the entry with orientation tag length = moveToTiffEntryWithTag ( is , length , tiffHeader . isLittleEndian , TIFF_TAG_ORIENTATION ) ; // read orientation return getOrientationFromTiffEntry ( is , length , tiffHeader . isLittleEndian ) ; }
Reads orientation information from TIFF data .