Setting gpsLatitudeRef and gpsLongitudeRef

Started by Archive, May 12, 2010, 08:53:56 AM

Previous topic - Next topic

Archive

[Originally posted by ccannell on 2006-10-06 16:22:16-07]

I'm trying to populate the exif or gps groups gps information (GPSLatitude, GPSLatitudeRef, GPSLongitude, GPSLongitudeRef, GPSAltitude and GPSAltitudeRef).  The file that I'm trying to populate already contains XMP:GPSLatitude and XMP:GPSLongitude a la Adobe Photoshop Elements 5.0.  The tags XMP:GPSLatitude and XMP:GPSLongitude already contain the hemisphere N/S/E/W info but EXIF:GPSLatitude and EXIF:GPSLongitude do not so I need to use GPSLongitudeRef and GPSLatitudeRef.  Is there an easy way to extract the N/S/E/W from XMP:GPSLatitude and XMP:GPSLongitude and populate GPSLongitudeRef and GPSLatitudeRef.  I'm doing this from the Windows command line.  The goal is to add gps metadata which flickr understands and parses using the gps metadata Adobe Photoshop Elements 5.0 adds to the files.  Thank you.

Archive

[Originally posted by exiftool on 2006-10-06 17:02:01-07]

This isn't simple, but it is do-able with the current release of ExifTool with user-defined tags.
First, be sure you have the most recent version of ExifTool since I've fixed some problems
with user-defined tags on Windows in version 6.45.

Then, create a file called ".ExifTool_config" in your home directory.  Cut and paste the following into that file:

Code:
# The %Image::ExifTool::UserDefined hash defines new tags to be
# added to existing tables.
%Image::ExifTool::UserDefined = (
    # Composite tags are added to the Composite table
    'Image::ExifTool::Composite' => {
        GPSLongitude2 => {
            Require => {
                0 => 'XMP:GPSLongitude',
            },
            ValueConv => 'abs($val[0])',
            PrintConv => 'Image::ExifTool::GPS::ToDMS($self,$val,1)',
        },
        GPSLatitude2 => {
            Require => {
                0 => 'XMP:GPSLatitude',
            },
            ValueConv => 'abs($val[0])',
            PrintConv => 'Image::ExifTool::GPS::ToDMS($self,$val,1)',
        },
        GPSLongitudeRef2 => {
            Require => {
                0 => 'XMP:GPSLongitude',
            },
            ValueConv => '$val[0] < 0 ? "W" : "E"',
            PrintConv => {
                E => 'East',
                W => 'West',
            },
        },
        GPSLatitudeRef2 => {
            Require => {
                0 => 'XMP:GPSLatitude',
            },
            ValueConv => '$val[0] < 0 ? "S" : "N"',
            PrintConv => {
                N => 'North',
                S => 'South',
            },
        },
    },
);

With this addition, you should be able to set the EXIF GPS tags like this:

Code:
exiftool "-gps:gpslatitude<gpslatitude2" "-gps:gpslongitude<gpslongitude2" "-gps:gpslatituderef<gpslatituderef2" "-gps:gpslongituderef<gpslongituderef2" image.jpg

Not pretty, but it should get the job done.

- Phil

Archive

[Originally posted by ccannell on 2006-10-06 19:31:27-07]

Phil,
   Thank you for the quick reply.  I believe I have followed your example exactly but I am getting "0 files changed, 1 file unchanged" when I perform this.  I'm not getting any errors but it is not making any changes to the file.  Are there some commands I can use to check that the ".ExifTool_config" file is correctly parsing everything.  You can reach me at ccannell {at} gmail.com if that would be easier.  I appreciate your help.

chris

Archive

[Originally posted by exiftool on 2006-10-06 23:31:04-07]

We found the problem by e-mail exchange.  Again problems with the environment
variables set in the shell.  ExifTool uses the first of the following variables that is
set to determine where the ".ExifTool_config" file is located:

1. EXIFTOOL_HOME

2. HOME

3. HOMEDRIVE + HOMEPATH (added in version 6.45)

If you ever have trouble with getting the user-defined tags to load from the config
file, check your shell environment (by typing "set" on windows, or "printenv" in a Unix
csh) to be sure that ExifTool can find the config file.

- Phil

P.S. I also realized that the user-defined GPSLatitude2/GPSLongitude2 tags were
unnecessary, since the GPS:GPSLatitude can be set directly from the XMP:GPSLatitude
(it just ignores the N/S/E/W).  So only the GPSLatitudeRef2/GPSLongitudeRef2
needed to be defined in the config file.