GeoNamesTagger utilises my self written java library “ExifToolWrapper”. The ExifToolWrapper library allows to read and write tags via ExifTool using a normal Java interface.

  • ExifToolWrapper documentation
  • Download: {filelink=8}
  • Features
    • Automatic target file backup copy handling
    • Automatic file session handling
    • So far, supports access to the following tags:
  •  

    TAG-Name Tag-Group Access
    ExifVersion EXIF r
    FlashpixVersion EXIF r
    ColorSpace EXIF r
    ComponentsConfiguration EXIF r
    CompressedBitsPerPixel EXIF r
    ExifImageWidth EXIF r
    ExifImageHeight EXIF r
    MakerNote EXIF r
    UserComment EXIF r
    RelatedSoundFile EXIF r
    DateTimeOriginal EXIF r
    CreateDate EXIF r
    SubSecTime EXIF r
    SubSecTimeOriginal EXIF r
    SubSecTimeDigitized EXIF r
    ExposureTime EXIF r
    FNumber EXIF r
    ExposureProgram EXIF r
    SpectralSensitivity EXIF r
    ISO EXIF r
    Opto-ElectricConvFactor EXIF r
    ShutterSpeedValue EXIF r
    ApertureValue EXIF r
    BrightnessValue EXIF r
    ExposureCompensation EXIF r
    MaxApertureValue EXIF r
    SubjectDistance EXIF r
    MeteringMode EXIF r
    LightSource EXIF r
    Flash EXIF r
    FocalLength EXIF r
    SubjectArea EXIF r
    FlashEnergy EXIF r
    SpatialFrequencyResponse EXIF r
    FocalPlaneXResolution EXIF r
    FocalPlaneYResolution EXIF r
    FocalPlaneResolutionUnit EXIF r
    SubjectLocation EXIF r
    ExposureIndex EXIF r
    SensingMethod EXIF r
    FileSource EXIF r
    SceneType EXIF r
    CustomRendered EXIF r
    ExposureMode EXIF r
    WhiteBalance EXIF r
    DigitalZoomRatio EXIF r
    FocalLengthIn35mmFormat EXIF r
    SceneCaptureType EXIF r
    GainControl EXIF r
    Contrast EXIF r
    Saturation EXIF r
    Sharpness EXIF r
    DeviceSettingDescription EXIF r
    SubjectDistanceRange EXIF r
    ImageUniqueID EXIF r
    Make IFD0 r
    Model IFD0 r
    Orientation IFD0 r
    XResolution IFD0 r
    YResolution IFD0 r
    ResolutionUnit IFD0 r
    Software IFD0 r
    ModifyDate IFD0 r
    GPSVersionID GPS r/w
    GPSLatitudeRef GPS r/w
    GPSLatitude GPS r/w
    GPSLongitudeRef GPS r/w
    GPSLongitude GPS r/w
    GPSAltitudeRef GPS r/w
    GPSAltitude GPS r/w
    GPSTimeStamp GPS r/w
    GPSSatellites GPS r/w
    GPSStatus GPS r/w
    GPSMeasureMode GPS r/w
    GPSDOP GPS r/w
    GPSSpeedRef GPS r/w
    GPSSpeed GPS r/w
    GPSTrackRef GPS r
    GPSTrack GPS r
    GPSImgDirectionRef GPS r/w
    GPSImgDirection GPS r/w
    GPSMapDatum GPS r/w
    GPSDestLatitudeRef GPS r/w
    GPSDestLatitude GPS r/w
    GPSDestLongitudeRef GPS r/w
    GPSDestLongitude GPS r/w
    GPSDestBearingRef GPS r/w
    GPSDestBearing GPS r/w
    GPSDestDistanceRef GPS r/w
    GPSDestDistance GPS r/w
    GPSProcessingMethod GPS r/w
    GPSAreaInformation GPS r/w
    GPSDateStamp GPS r/w
    GPSDifferential GPS r/w
    Keywords IPTC r/w
    City IPTC r/w
    Sub-location IPTC r/w
    Province-State IPTC r/w
    Country-PrimaryLocationCode IPTC r/w
    Country-PrimaryLocationName IPTC r/w
    GPSVersionID XMP_EXIF r/w
    GPSMapDatum XMP_EXIF r
    GPSDateTime XMP_EXIF r/w
    CountryCode XMP_IPTCCORE r/w
    Location XMP_IPTCCORE r/w
    Subject XMP_DC r/w
    City XMP_PHOTOSHOP r/w
    Country XMP_PHOTOSHOP r/w
    State XMP_PHOTOSHOP r/w
    Make XMP_TIFF r/w
    CreateDate XMP_XMP r/w
  • Usage example
  • UUID sessionID = null;
    try {
    	sessionID = etw.openSession(file);
    	ImageMetaData data = etw.getMetaData(sessionID);
    	data.setGPSLatitude(info.latitude);
    	data.setGPSLongitude(info.longitude);
     
    	KeywordWriteBehaviour behaviour = KeywordWriteBehaviour.ADD_NO_DOUBLE_ENTRIES;
    	if(true == info.overwriteKeywords) {
    		behaviour = KeywordWriteBehaviour.OVERWRITE;
    	}
     
    	data.setIptcCity("City Name", LocationWriteBehaviour.DEL_CORRESPONDING_KEYWORDS);
    	data.setIptcCountryPrimaryLocationCode("XYZ", LocationWriteBehaviour.DEL_CORRESPONDING_KEYWORDS);
    	data.setIptcCountryPrimaryLocationName("Country Name", LocationWriteBehaviour.DEL_CORRESPONDING_KEYWORDS);
    	data.setIptcProvinceState("State Name", LocationWriteBehaviour.DEL_CORRESPONDING_KEYWORDS);
    	data.setIptcSubLocation("Sublocation Name", LocationWriteBehaviour.DEL_CORRESPONDING_KEYWORDS);
     
    	List keywords = new List();
    	keywords.add("City Name");
    	keywords.add("Country Name");
    	keywords.add("Another Keyword");
     
    	data.setIptcKeywords(keywords, behaviour);
    	data.setXmpCity("City Name", LocationWriteBehaviour.DEL_CORRESPONDING_KEYWORDS);
    	data.setXmpCountryCode("XYZ", LocationWriteBehaviour.DEL_CORRESPONDING_KEYWORDS);
    	data.setXmpCountry("Country Name", LocationWriteBehaviour.DEL_CORRESPONDING_KEYWORDS);
    	data.setXmpState("State Name", LocationWriteBehaviour.DEL_CORRESPONDING_KEYWORDS);
    	data.setXmpLocation("Sublocation Name", LocationWriteBehaviour.DEL_CORRESPONDING_KEYWORDS);
    	data.setXmpKeywords(keywords, behaviour);
     
    	if(true == etw.writeMultipleTags(sessionID, data, info.tagWriteSet)) {
    		etw.commitSession(sessionID);
    	} else {
    		etw.rollbackSession(sessionID);
    	}
    } catch(IllegalArgumentException e) {
    	logger.fatal("Could not update metadata: " + e.getMessage());
    	try {
    		etw.rollbackSession(sessionID);
    	} catch (InvalidKeyException ex) {}
    } catch (InvalidKeyException e) {
    	logger.fatal("Could not initiate session: " + e.getMessage());
    	try {
    		etw.rollbackSession(sessionID);
    	} catch (InvalidKeyException ex) {}
    } catch (ExifToolWrapperOperationException e) {
    	logger.fatal("Exiftool operation failed: " + e.getMessage());
    	try {
    		etw.rollbackSession(sessionID);
    	} catch (InvalidKeyException ex) {}
    }