Class ExifReader

java.lang.Object
org.openstreetmap.josm.tools.ExifReader

public final class ExifReader extends Object
Read out EXIF information from a JPEG file
Since:
99
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getRestoreOrientationTransform(int orientation, int width, int height)
    Returns a Transform that fixes the image orientation.
    static boolean
    orientationNeedsCorrection(int orientation)
    Check, if the given orientation requires any correction to the image.
    static boolean
    Check, if the given orientation switches width and height of the image.
    private static double
    readAxis(com.drew.metadata.exif.GpsDirectory dirGps, int gpsTag, int gpsTagRef, char cRef)
     
    static String
    readCaption(com.drew.metadata.iptc.IptcDirectory dirIptc)
    Returns the caption of the given IPTC directory.
    static Double
    readDirection(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the direction of the given EXIF GPS directory.
    static Double
    readDirection(File filename)
    Returns the direction of the given JPEG file.
    static Double
    readElevation(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the elevation of the given EXIF GPS directory.
    static Double
    readElevation(File filename)
    Returns the elevation of the given JPEG file.
    static String
    readGpsDatum(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the GPS datum value of the given EXIF GPS directory.
    static String
    readGpsDatum(File filename)
    Returns the GPS datum value of the given JPEG file.
    static Integer
    readGpsDiffMode(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the GPS differential mode of the given EXIF GPS directory.
    static Integer
    Returns the GPS differential mode of the given JPEG file.
    static Double
    readGpsDop(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the GPS DOP value of the given EXIF GPS directory.
    static Double
    readGpsDop(File filename)
    Returns the GPS DOP value of the given JPEG file.
    static Instant
    readGpsInstant(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the GPS date/time from the given JPEG file.
    static Instant
    readGpsInstant(File filename)
    Returns the GPS date/time from the given JPEG file.
    static Integer
    readGpsMeasureMode(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the GPS 2d/3d mode of the given EXIF GPS directory.
    static Integer
    Returns the GPS 2d/3d mode of the given JPEG file.
    static String
    readGpsProcessingMethod(com.drew.metadata.exif.GpsDirectory dirGps)
    Return the GPS processing method of the given EXIF GPS directory.
    static String
    Return the GPS processing method of the given JPEG file.
    static Double
    readGpsTrackDirection(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the GPS track direction of the given EXIF GPS directory.
    static Double
    Returns the GPS track direction of the given JPEG file.
    static String
    readHeadline(com.drew.metadata.iptc.IptcDirectory dirIptc)
    Returns the headline of the given IPTC directory.
    static Double
    readHpositioningError(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the GPS horizontal positionning error of the given EXIF GPS directory.
    static Double
    Returns the GPS horizontal positionning error of the given JPEG file.
    static Instant
    readInstant(com.drew.metadata.Metadata metadata)
    Returns the date/time from the given JPEG file.
    static Instant
    readInstant(File filename)
    Returns the date/time from the given JPEG file.
    static List<String>
    readKeywords(com.drew.metadata.iptc.IptcDirectory dirIptc)
    Returns the keywords of the given IPTC directory.
    static LatLon
    readLatLon(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the geolocation of the given EXIF GPS directory.
    static LatLon
    readLatLon(File filename)
    Returns the geolocation of the given JPEG file.
    static String
    readObjectName(com.drew.metadata.iptc.IptcDirectory dirIptc)
    Returns the object name of the given IPTC directory.
    static Integer
    Returns the image orientation of the given JPEG file.
    static Double
    readSpeed(com.drew.metadata.exif.GpsDirectory dirGps)
    Returns the speed of the given EXIF GPS directory.
    static Double
    readSpeed(File filename)
    Returns the speed of the given JPEG file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • readInstant

      public static Instant readInstant(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 null if not found
    • readInstant

      public static 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 null if not found
    • readGpsInstant

      public static Instant readGpsInstant(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 null if not found
      Since:
      19387
    • readGpsInstant

      public static 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 null if not found
      Since:
      19387
    • readOrientation

      public static Integer readOrientation(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:
      1. The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.
      2. The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.
      3. The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.
      4. The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.
      5. The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.
      6. The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.
      7. The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.
      8. The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.
      See Also:
    • readLatLon

      public static LatLon readLatLon(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 null if 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 null if dirGps is null
      Throws:
      com.drew.metadata.MetadataException - if invalid metadata is given
      Since:
      6209
    • readDirection

      public static Double readDirection(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 null if not found
      Since:
      6209
    • readDirection

      public static 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 null if missing or if dirGps is null
      Since:
      6209
    • readGpsTrackDirection

      public static Double readGpsTrackDirection(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 null if not found
      Since:
      19387
    • readGpsTrackDirection

      public static 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 null if missing or if dirGps is 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 Double readSpeed(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 null if not found
      Since:
      11745
    • readSpeed

      public static 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 null if missing or if dirGps is null
      Since:
      11745
    • readElevation

      public static Double readElevation(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 null if not found
      Since:
      11745
    • readElevation

      public static 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 null if missing or if dirGps is null
      Since:
      11745
    • readHpositioningError

      public static Double readHpositioningError(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 null if not found
      Since:
      19387
    • readHpositioningError

      public static 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 null if missing or if dirGps is null
      Since:
      19387
    • readGpsDiffMode

      public static Integer readGpsDiffMode(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 null if not found
      Since:
      19387
    • readGpsDiffMode

      public static 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 null if missing or if dirGps is null
      Since:
      19387
    • readGpsMeasureMode

      public static Integer readGpsMeasureMode(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 null if not found
      Since:
      19387
    • readGpsMeasureMode

      public static 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 null if missing or if dirGps is null
      Since:
      19387
    • readGpsDop

      public static Double readGpsDop(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 null if not found
      Since:
      19387
    • readGpsDop

      public static 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 null if missing or if dirGps is null
      Since:
      19387
    • readGpsDatum

      public static String readGpsDatum(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 null if not found
      Since:
      19387
    • readGpsDatum

      public static 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 null if missing or if dirGps is null
      Since:
      19387
    • readGpsProcessingMethod

      public static String readGpsProcessingMethod(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
      Other values, and combined space separated values are possible too. or null if missing
      Since:
      19387
    • readGpsProcessingMethod

      public static 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
      Other values, and combined space separated values are possible too. or null if missing or if dirGps is null
      Since:
      19387
    • readCaption

      public static 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 null if missing or if dirIptc is null
      Since:
      15219
    • readHeadline

      public static 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 null if missing or if dirIptc is null
      Since:
      15219
    • readKeywords

      public static List<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 null if missing or if dirIptc is null
      Since:
      15219
    • readObjectName

      public static 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 null if missing or if dirIptc is null
      Since:
      15219
    • getRestoreOrientationTransform

      public static 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 image
      width - the original width of the image
      height - 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 rotation

      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, 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.