How to write an empty XMP-exif:GPSLatitude or XMP-exif:GPSLongitude tag?

Started by Piz Bernina, November 27, 2022, 12:35:57 PM

Previous topic - Next topic

Piz Bernina

Hi folks,

Is there a way to write an empty string to XMP tags whose values Exiftool internally converts to any sort of number format (e.g. GPSLatitude, GPSLongitude, etc.)?

For example, the command
exiftool -XMP:GPSLatitude^= test.xmpproduces the following error message:
Warning: Error converting value for XMP-exif:GPSLatitude (ValueConvInv)
Why is it important to me?
I have some raw files with XMP sidecars. These files may contain metadata informations that I want to remove. Since I don't want to change the raw files themselves, I need to write the changes to the sidecars. An empty GPSLatitude tag in the XMP sidecar tells an image viewer not to display the GPSLatitude value of the raw image file. At least, this is (more or less) the way Adobe Bridge handles metadata reconciliation in this case.

Any suggestions?

StarGeek

In most cases, you would use the -n (--printConv) option, but that doesn't appear to work in this case.

Phil will have to weigh in on this.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Writing an empty string doesn't work for fixed-format tags.  Unfortunately this is treated as a fixed-format tag because the EXIF-for-XMP specification requires a specific format.

You can write an arbitrary string by overriding the XMP-exif GPS tags with your own.  Here is the config file:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::XMP::exif' => {
        GPSLatitude => { },
        GPSLongitude => { },
    },
);
1; #end

- 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 ($).

Piz Bernina

Quote from: Phil Harvey on November 27, 2022, 09:15:00 PMYou can write an arbitrary string by overriding the XMP-exif GPS tags with your own.     

That's exactly what I was looking for. My program will have to generate the config files dynamically depending on which tags need to be emptied. But that's no big deal. Thanks Phil, you made my day ;)!

Phil Harvey

Note that technically this is an invalid value because it isn't mentioned in the EXIF-for-XMP specification, so other apps may balk at XMP with entries like this.

- 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 ($).

Piz Bernina

Quote from: Phil Harvey on November 28, 2022, 07:42:45 AMNote that technically this is an invalid value because it isn't mentioned in the EXIF-for-XMP specification, so other apps may balk at XMP with entries like this.

I played around with Adobe Bridge a little more. When you delete a GPS coordinate, it writes an empty string to the corresponding tag in the XMP sidecar, as i said. But if you delete the altitude, it writes a zero value ("0/100"). I think this is because the type of GPS coordinates is "Text" and the type of the altitude is "Rational".

But then again, the XMP spec says:
QuoteThe schemas define a set of properties. In any given XMP, a property may be absent or present:
  • Absent: The property has no value. Properties are absent until given a value for the first time.
  • Present: The property has a defined value. A present property may have the empty string as its value; this is different from an absent property. However, writers are encouraged not to set properties with a value of the empty string.

Doesn't this mean that any property can contain an empty string, regardless of the data type?

Phil Harvey

This is part of the EXIF for XMP specification, which says that a "Text" value may be empty.  But the GPS coordinates are of type "GPSCoordinate", and the Altitude is "Rational" as you mentioned.  It says this about GPSCoordinate:

QuoteValue type of GPSCoodinate is a Text value in the form "DDD,MM,SSk" or "DDD,MM.mmk", ...

and this about Rational:

QuoteTo represent Exif rational values in XMP, they must be converted to text. The recommended approach is to use a value of type Text of the form numerator /denominator. For example, the value 2/3 becomes the text value "2/3" when converted to XMP.

But as usual, the people who wrote the EXIF specification are braindead when it comes to providing usable documentation.

- 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 ($).

Piz Bernina

Quote from: Phil Harvey on November 28, 2022, 07:18:47 PMBut as usual, the people who wrote the EXIF specification are braindead when it comes to providing usable documentation.
I won't contradict you ...  ;)

Anyway, you convinced me not to use empty strings for non-text properties. That's a pity, because empty tags seemed like a rather elegant solution to my problem. But they can lead to null pointer problems with other programs, as you said.