Package org.openstreetmap.josm.tools
Class ExifReader
- java.lang.Object
-
- org.openstreetmap.josm.tools.ExifReader
-
public final class ExifReader extends java.lang.Object
Read out EXIF information from a JPEG file- Since:
- 99
-
-
Constructor Summary
Constructors Modifier Constructor Description privateExifReader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.geom.AffineTransformgetRestoreOrientationTransform(int orientation, int width, int height)Returns a Transform that fixes the image orientation.static booleanorientationNeedsCorrection(int orientation)Check, if the given orientation requires any correction to the image.static booleanorientationSwitchesDimensions(int orientation)Check, if the given orientation switches width and height of the image.private static doublereadAxis(com.drew.metadata.exif.GpsDirectory dirGps, int gpsTag, int gpsTagRef, char cRef)static java.lang.StringreadCaption(com.drew.metadata.iptc.IptcDirectory dirIptc)Returns the caption of the given IPTC directory.static java.lang.DoublereadDirection(com.drew.metadata.exif.GpsDirectory dirGps)Returns the direction of the given EXIF GPS directory.static java.lang.DoublereadDirection(java.io.File filename)Returns the direction of the given JPEG file.static java.lang.DoublereadElevation(com.drew.metadata.exif.GpsDirectory dirGps)Returns the elevation of the given EXIF GPS directory.static java.lang.DoublereadElevation(java.io.File filename)Returns the elevation of the given JPEG file.static java.lang.StringreadGpsDatum(com.drew.metadata.exif.GpsDirectory dirGps)Returns the GPS datum value of the given EXIF GPS directory.static java.lang.StringreadGpsDatum(java.io.File filename)Returns the GPS datum value of the given JPEG file.static java.lang.IntegerreadGpsDiffMode(com.drew.metadata.exif.GpsDirectory dirGps)Returns the GPS differential mode of the given EXIF GPS directory.static java.lang.IntegerreadGpsDiffMode(java.io.File filename)Returns the GPS differential mode of the given JPEG file.static java.lang.DoublereadGpsDop(com.drew.metadata.exif.GpsDirectory dirGps)Returns the GPS DOP value of the given EXIF GPS directory.static java.lang.DoublereadGpsDop(java.io.File filename)Returns the GPS DOP value of the given JPEG file.static java.time.InstantreadGpsInstant(com.drew.metadata.exif.GpsDirectory dirGps)Returns the GPS date/time from the given JPEG file.static java.time.InstantreadGpsInstant(java.io.File filename)Returns the GPS date/time from the given JPEG file.static java.lang.IntegerreadGpsMeasureMode(com.drew.metadata.exif.GpsDirectory dirGps)Returns the GPS 2d/3d mode of the given EXIF GPS directory.static java.lang.IntegerreadGpsMeasureMode(java.io.File filename)Returns the GPS 2d/3d mode of the given JPEG file.static java.lang.StringreadGpsProcessingMethod(com.drew.metadata.exif.GpsDirectory dirGps)Return the GPS processing method of the given EXIF GPS directory.static java.lang.StringreadGpsProcessingMethod(java.io.File filename)Return the GPS processing method of the given JPEG file.static java.lang.DoublereadGpsTrackDirection(com.drew.metadata.exif.GpsDirectory dirGps)Returns the GPS track direction of the given EXIF GPS directory.static java.lang.DoublereadGpsTrackDirection(java.io.File filename)Returns the GPS track direction of the given JPEG file.static java.lang.StringreadHeadline(com.drew.metadata.iptc.IptcDirectory dirIptc)Returns the headline of the given IPTC directory.static java.lang.DoublereadHpositioningError(com.drew.metadata.exif.GpsDirectory dirGps)Returns the GPS horizontal positionning error of the given EXIF GPS directory.static java.lang.DoublereadHpositioningError(java.io.File filename)Returns the GPS horizontal positionning error of the given JPEG file.static java.time.InstantreadInstant(com.drew.metadata.Metadata metadata)Returns the date/time from the given JPEG file.static java.time.InstantreadInstant(java.io.File filename)Returns the date/time from the given JPEG file.static java.util.List<java.lang.String>readKeywords(com.drew.metadata.iptc.IptcDirectory dirIptc)Returns the keywords of the given IPTC directory.static LatLonreadLatLon(com.drew.metadata.exif.GpsDirectory dirGps)Returns the geolocation of the given EXIF GPS directory.static LatLonreadLatLon(java.io.File filename)Returns the geolocation of the given JPEG file.static java.lang.StringreadObjectName(com.drew.metadata.iptc.IptcDirectory dirIptc)Returns the object name of the given IPTC directory.static java.lang.IntegerreadOrientation(java.io.File filename)Returns the image orientation of the given JPEG file.static java.lang.DoublereadSpeed(com.drew.metadata.exif.GpsDirectory dirGps)Returns the speed of the given EXIF GPS directory.static java.lang.DoublereadSpeed(java.io.File filename)Returns the speed of the given JPEG file.
-
-
-
Constructor Detail
-
ExifReader
private ExifReader()
-
-
Method Detail
-
readInstant
public static java.time.Instant readInstant(java.io.File filename)
Returns the date/time from the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The date/time read in the EXIF section, or
nullif not found
-
readInstant
public static java.time.Instant readInstant(com.drew.metadata.Metadata metadata)
Returns the date/time from the given JPEG file.- Parameters:
metadata- The EXIF metadata- Returns:
- The date/time read in the EXIF section, or
nullif not found
-
readGpsInstant
public static java.time.Instant readGpsInstant(java.io.File filename)
Returns the GPS date/time from the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The GPS date/time read in the EXIF section, or
nullif not found - Since:
- 19387
-
readGpsInstant
public static java.time.Instant readGpsInstant(com.drew.metadata.exif.GpsDirectory dirGps)
Returns the GPS date/time from the given JPEG file.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The GPS date/time read in the EXIF section, or
nullif not found - Since:
- 19387
-
readOrientation
public static java.lang.Integer readOrientation(java.io.File filename)
Returns the image orientation of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The image orientation as an
int. Default value is 1. Possible values are listed in EXIF spec as follows:- The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.
- The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.
- The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.
- The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.
- The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.
- The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.
- The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.
- The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.
- See Also:
- http://www.impulseadventure.com/photo/exif-orientation.html, http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto
-
readLatLon
public static LatLon readLatLon(java.io.File filename)
Returns the geolocation of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The lat/lon read in the EXIF section, or
nullif not found - Since:
- 6209
-
readLatLon
public static LatLon readLatLon(com.drew.metadata.exif.GpsDirectory dirGps) throws com.drew.metadata.MetadataException
Returns the geolocation of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The lat/lon read in the EXIF section, or
nullifdirGpsis null - Throws:
com.drew.metadata.MetadataException- if invalid metadata is given- Since:
- 6209
-
readDirection
public static java.lang.Double readDirection(java.io.File filename)
Returns the direction of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The direction of the image when it was captures (in degrees between 0.0 and 359.99),
or
nullif not found - Since:
- 6209
-
readDirection
public static java.lang.Double readDirection(com.drew.metadata.exif.GpsDirectory dirGps)
Returns the direction of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The direction of the image when it was captured (in degrees between 0.0 and 359.99),
or
nullif missing or ifdirGpsis null - Since:
- 6209
-
readGpsTrackDirection
public static java.lang.Double readGpsTrackDirection(java.io.File filename)
Returns the GPS track direction of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The GPS track direction of the image when it was captures (in degrees between 0.0 and 359.99),
or
nullif not found - Since:
- 19387
-
readGpsTrackDirection
public static java.lang.Double readGpsTrackDirection(com.drew.metadata.exif.GpsDirectory dirGps)
Returns the GPS track direction of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The GPS track direction of the image when it was captured (in degrees between 0.0 and 359.99),
or
nullif missing or ifdirGpsis null - Since:
- 19387
-
readAxis
private static double readAxis(com.drew.metadata.exif.GpsDirectory dirGps, int gpsTag, int gpsTagRef, char cRef) throws com.drew.metadata.MetadataException
- Throws:
com.drew.metadata.MetadataException
-
readSpeed
public static java.lang.Double readSpeed(java.io.File filename)
Returns the speed of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The speed of the camera when the image was captured (in km/h),
or
nullif not found - Since:
- 11745
-
readSpeed
public static java.lang.Double readSpeed(com.drew.metadata.exif.GpsDirectory dirGps)
Returns the speed of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The speed of the camera when the image was captured (in km/h),
or
nullif missing or ifdirGpsis null - Since:
- 11745
-
readElevation
public static java.lang.Double readElevation(java.io.File filename)
Returns the elevation of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The elevation of the camera when the image was captured (in m),
or
nullif not found - Since:
- 11745
-
readElevation
public static java.lang.Double readElevation(com.drew.metadata.exif.GpsDirectory dirGps)
Returns the elevation of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The elevation of the camera when the image was captured (in m),
or
nullif missing or ifdirGpsis null - Since:
- 11745
-
readHpositioningError
public static java.lang.Double readHpositioningError(java.io.File filename)
Returns the GPS horizontal positionning error of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The GPS horizontal positionning error of the camera when the image was captured (in m),
or
nullif not found - Since:
- 19387
-
readHpositioningError
public static java.lang.Double readHpositioningError(com.drew.metadata.exif.GpsDirectory dirGps)
Returns the GPS horizontal positionning error of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The GPS horizontal positionning error of the camera when the image was captured (in m),
or
nullif missing or ifdirGpsis null - Since:
- 19387
-
readGpsDiffMode
public static java.lang.Integer readGpsDiffMode(java.io.File filename)
Returns the GPS differential mode of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The GPS differential mode of the camera when the image was captured,
- 0 : no differential correction
- 1 : differential correction
- or
nullif not found
- Since:
- 19387
-
readGpsDiffMode
public static java.lang.Integer readGpsDiffMode(com.drew.metadata.exif.GpsDirectory dirGps)
Returns the GPS differential mode of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The GPS differential mode of the camera when the image was captured,
- 0 : no differential correction
- 1 : differential correction
- or
nullif missing or ifdirGpsis null
- Since:
- 19387
-
readGpsMeasureMode
public static java.lang.Integer readGpsMeasureMode(java.io.File filename)
Returns the GPS 2d/3d mode of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The GPS 2d/3d mode of the camera when the image was captured,
- 2 : 2d mode
- 2 : 3d mode
- or
nullif not found
- Since:
- 19387
-
readGpsMeasureMode
public static java.lang.Integer readGpsMeasureMode(com.drew.metadata.exif.GpsDirectory dirGps)
Returns the GPS 2d/3d mode of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The 2d/3d mode of the camera when the image was captured,
- 2 : 2d mode
- 3 : 3d mode
- or
nullif missing or ifdirGpsis null
- Since:
- 19387
-
readGpsDop
public static java.lang.Double readGpsDop(java.io.File filename)
Returns the GPS DOP value of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The GPS DOP value of the camera when the image was captured,
or
nullif not found - Since:
- 19387
-
readGpsDop
public static java.lang.Double readGpsDop(com.drew.metadata.exif.GpsDirectory dirGps)
Returns the GPS DOP value of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The GPS DOP value of the camera when the image was captured,
or
nullif missing or ifdirGpsis null - Since:
- 19387
-
readGpsDatum
public static java.lang.String readGpsDatum(java.io.File filename)
Returns the GPS datum value of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The GPS datum value of the camera when the image was captured,
or
nullif not found - Since:
- 19387
-
readGpsDatum
public static java.lang.String readGpsDatum(com.drew.metadata.exif.GpsDirectory dirGps)
Returns the GPS datum value of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The GPS datum value of the camera when the image was captured,
or
nullif missing or ifdirGpsis null - Since:
- 19387
-
readGpsProcessingMethod
public static java.lang.String readGpsProcessingMethod(java.io.File filename)
Return the GPS processing method of the given JPEG file.- Parameters:
filename- The JPEG file to read- Returns:
- The GPS processing method. Possible values from the EXIF specs are:
- GPS
- QZSS
- GALILEO
- GLONASS
- BEIDOU
- NAVIC
- CELLID
- WLAN
- MANUAL
nullif missing - Since:
- 19387
-
readGpsProcessingMethod
public static java.lang.String readGpsProcessingMethod(com.drew.metadata.exif.GpsDirectory dirGps)
Return the GPS processing method of the given EXIF GPS directory.- Parameters:
dirGps- The EXIF GPS directory- Returns:
- The GPS processing method. Possible values from the EXIF specs are:
- GPS
- QZSS
- GALILEO
- GLONASS
- BEIDOU
- NAVIC
- CELLID
- WLAN
- MANUAL
nullif missing or ifdirGpsis null - Since:
- 19387
-
readCaption
public static java.lang.String readCaption(com.drew.metadata.iptc.IptcDirectory dirIptc)
Returns the caption of the given IPTC directory.- Parameters:
dirIptc- The IPTC directory- Returns:
- The caption entered, or
nullif missing or ifdirIptcis null - Since:
- 15219
-
readHeadline
public static java.lang.String readHeadline(com.drew.metadata.iptc.IptcDirectory dirIptc)
Returns the headline of the given IPTC directory.- Parameters:
dirIptc- The IPTC directory- Returns:
- The headline entered, or
nullif missing or ifdirIptcis null - Since:
- 15219
-
readKeywords
public static java.util.List<java.lang.String> readKeywords(com.drew.metadata.iptc.IptcDirectory dirIptc)
Returns the keywords of the given IPTC directory.- Parameters:
dirIptc- The IPTC directory- Returns:
- The keywords entered, or
nullif missing or ifdirIptcis null - Since:
- 15219
-
readObjectName
public static java.lang.String readObjectName(com.drew.metadata.iptc.IptcDirectory dirIptc)
Returns the object name of the given IPTC directory.- Parameters:
dirIptc- The IPTC directory- Returns:
- The object name entered, or
nullif missing or ifdirIptcis null - Since:
- 15219
-
getRestoreOrientationTransform
public static java.awt.geom.AffineTransform getRestoreOrientationTransform(int orientation, int width, int height)
Returns a Transform that fixes the image orientation.Only orientation 1, 3, 6 and 8 are supported. Everything else is treated as 1.
- Parameters:
orientation- the exif-orientation of the imagewidth- the original width of the imageheight- the original height of the image- Returns:
- a transform that rotates the image, so it is upright
-
orientationSwitchesDimensions
public static boolean orientationSwitchesDimensions(int orientation)
Check, if the given orientation switches width and height of the image. E.g. 90 degree rotationOnly orientation 1, 3, 6 and 8 are supported. Everything else is treated as 1.
- Parameters:
orientation- the exif-orientation of the image- Returns:
- true, if it switches width and height
-
orientationNeedsCorrection
public static boolean orientationNeedsCorrection(int orientation)
Check, if the given orientation requires any correction to the image.Only orientation 1, 3, 6 and 8 are supported. Everything else is treated as 1.
- Parameters:
orientation- the exif-orientation of the image- Returns:
- true, unless the orientation value is 1 or unsupported.
-
-