Source:
<code>private static MapillaryImportedImage readImageFrom( final InputStream is, final File f, final LatLon defaultLL ) throws IOException { Object latRef = null; Object lonRef = null; Object lat = null; Object lon = null; Object gpsDir = null; Object dateTime = null; final ImageMetadata meta; try { meta = Imaging.getMetadata(is, null); if (meta instanceof JpegImageMetadata) { final JpegImageMetadata jpegMeta = (JpegImageMetadata) meta; latRef = getTiffFieldValue(jpegMeta, GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF); lonRef = getTiffFieldValue(jpegMeta, GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF); lat = getTiffFieldValue(jpegMeta, GpsTagConstants.GPS_TAG_GPS_LATITUDE); lon = getTiffFieldValue(jpegMeta, GpsTagConstants.GPS_TAG_GPS_LONGITUDE); gpsDir = getTiffFieldValue(jpegMeta, GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION); dateTime = getTiffFieldValue(jpegMeta, ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); } } catch (ImageReadException e) { } final LatLon latLon; if (lat instanceof RationalNumber[] && latRef != null && lon instanceof RationalNumber[] && lonRef != null) { latLon = new LatLon( MapillaryUtils.degMinSecToDouble((RationalNumber[]) lat, latRef.toString()), MapillaryUtils.degMinSecToDouble((RationalNumber[]) lon, lonRef.toString()) ); } else { latLon = defaultLL; } final double ca; if (gpsDir instanceof RationalNumber) { ca = ((RationalNumber) gpsDir).doubleValue(); } else { ca = 0; } FileInputStream nis = new FileInputStream(f); <START> boolean pano = ImageMetaDataUtil.getPanorama(nis); <END> if (dateTime == null) { return new MapillaryImportedImage(latLon, ca, f, pano); } return new MapillaryImportedImage(latLon, ca, f, pano, dateTime.toString()); }</code><technical_language>FileInputStream closed</technical_language>

Target:
private static MapillaryImportedImage readImageFrom( final InputStream is, final File f, final LatLon defaultLL ) throws IOException { Object latRef = null; Object lonRef = null; Object lat = null; Object lon = null; Object gpsDir = null; Object dateTime = null; final ImageMetadata meta; try { meta = Imaging.getMetadata(is, null); if (meta instanceof JpegImageMetadata) { final JpegImageMetadata jpegMeta = (JpegImageMetadata) meta; latRef = getTiffFieldValue(jpegMeta, GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF); lonRef = getTiffFieldValue(jpegMeta, GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF); lat = getTiffFieldValue(jpegMeta, GpsTagConstants.GPS_TAG_GPS_LATITUDE); lon = getTiffFieldValue(jpegMeta, GpsTagConstants.GPS_TAG_GPS_LONGITUDE); gpsDir = getTiffFieldValue(jpegMeta, GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION); dateTime = getTiffFieldValue(jpegMeta, ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); } } catch (ImageReadException e) { } final LatLon latLon; if (lat instanceof RationalNumber[] && latRef != null && lon instanceof RationalNumber[] && lonRef != null) { latLon = new LatLon( MapillaryUtils.degMinSecToDouble((RationalNumber[]) lat, latRef.toString()), MapillaryUtils.degMinSecToDouble((RationalNumber[]) lon, lonRef.toString()) ); } else { latLon = defaultLL; } final double ca; if (gpsDir instanceof RationalNumber) { ca = ((RationalNumber) gpsDir).doubleValue(); } else { ca = 0; } boolean pano = ImageMetaDataUtil.isPanorama(f); if (dateTime == null) { return new MapillaryImportedImage(latLon, ca, f, pano); } return new MapillaryImportedImage(latLon, ca, f, pano, dateTime.toString()); }