private static int moveToAPP1EXIF ( InputStream is ) throws IOException { if ( moveToMarker ( is , MARKER_APP1 ) ) { // read block length // subtract 2 as length contain SIZE field we just read int length = StreamProcessor . readPackedInt ( is , 2 , false ) - 2 ; if ( length > 6 ) { int magic = StreamProcessor . readPackedInt ( is , 4 , false ) ; length -= 4 ; int zero = StreamProcessor . readPackedInt ( is , 2 , false ) ; length -= 2 ; if ( magic == APP1_EXIF_MAGIC && zero == 0 ) { // JEITA CP-3451 Exif Version 2.2 return length ; } } } return 0 ; }
Positions the given input stream to the beginning of the EXIF data in the JPEG APP1 block .