Duplicate entries: $exifTool->SetNewValue('EXIF:GPSLatitude', $newLatitude);

Started by outdoormagic, March 02, 2022, 11:06:41 AM

Previous topic - Next topic

outdoormagic

Good morning everyone,

I have duplicate tags, such as described in this post: https://exiftool.org/forum/index.php?topic=4710.0, where Phil suggested a solution using the application interface, i.e., something like

    exiftool -author= FILE.

What is the PERL equivalent of deleting a tag? Phil mentions later in the post that I can use something like:

    # delete key
    $exifTool->SetNewValue('EXIF:GPSLatitude');
    $exifTool->WriteInfo($file);
    # write new value
    $exifTool->SetNewValue('EXIF:GPSLatitude', $newLatitude);
    $exifTool->WriteInfo($file);


However, I still have the duplicates.

[EDIT]
It appears that the deletion works just fine. However, when I call

    $exifTool->SetNewValue('EXIF:GPSLongitude' => $refLon, AddValue => 0);
    $exifTool->WriteInfo($file);

or
    $exifTool->SetNewValue('GPSLongitude' => $refLon, Group => 'EXIF', AddValue => 0);
    $exifTool->WriteInfo($file);

two (2) entries are created. This doesn't happen for the 'XMP' group.

This particular file is a Lumix .RW2 file, so EXIF should be ok, right?
[/EDIT]

Thank you,

Paul


Additional information:

Alternatively, I tried using code such as

$exifTool->SetNewValue('EXIF:GPSLatitude' => abs($newLatitudeValue), AddValue => 0);

to overwrite existing values, but that doesn't work. If I check the PERL-processed file with

exiftool -a -G FILE

I get something like this:

'[Composite]     GPS Altitude                    : 30 m Below Sea Level'
'[Composite]     GPS Altitude                    : 30 m Below Sea Level'
'[Composite]     GPS Latitude                    : 10 deg 0\' 0.00" N'
'[Composite]     GPS Latitude                    : 10 deg 0\' 0.00" N'
'[Composite]     GPS Latitude Ref                : North'
'[Composite]     GPS Longitude                   : 20 deg 0\' 0.00" E'
'[Composite]     GPS Longitude                   : 20 deg 0\' 0.00" E'
'[Composite]     GPS Longitude Ref               : East'
'[Composite]     GPS Position                    : 10 deg 0\' 0.00" N, 20 deg 0\' 0.00" E'
'[EXIF]          GPS Altitude                    : 30 m'
'[EXIF]          GPS Altitude                    : 30 m'
'[EXIF]          GPS Altitude Ref                : Below Sea Level'
'[EXIF]          GPS Altitude Ref                : Below Sea Level'
'[EXIF]          GPS Latitude                    : 10 deg 0\' 0.00"'
'[EXIF]          GPS Latitude                    : 10 deg 0\' 0.00"'
'[EXIF]          GPS Latitude Ref                : North'
'[EXIF]          GPS Latitude Ref                : North'
'[EXIF]          GPS Longitude                   : 20 deg 0\' 0.00"'
'[EXIF]          GPS Longitude                   : 20 deg 0\' 0.00"'
'[EXIF]          GPS Longitude Ref               : East'
'[EXIF]          GPS Longitude Ref               : East'
'[XMP]           GPS Altitude                    : 30 m'
'[XMP]           GPS Altitude Ref                : Below Sea Level'
'[XMP]           GPS Latitude                    : 10 deg 0\' 0.00" N'
'[XMP]           GPS Longitude                   : 20 deg 0\' 0.00" E'



Phil Harvey

It seems there are 2 EXIF groups in the RW2 file -- one in the top-level TIFF package, and one in the embedded JPEG image.  You can use the -G5 option when extracting to see more details about exactly where these are located.  ExifTool writes both of these.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

outdoormagic