Tag 'XMP:XMP-MicrosoftPhoto_1_:Rating' does not exist

Started by Hayo Baan, June 20, 2014, 11:43:10 AM

Previous topic - Next topic

Hayo Baan

Hi Phil,

Sorry to bother you again ;-)

This time I can't write to the 'XMP:XMP-MicrosoftPhoto_1_:Rating' tag. Any idea as to why this is this time?

Note: in the documentation I do find a reference to the RatingPercent tag, but not to the Microsoft Rating tag (though the values I get from this tag are actually the percentages you mentioned). I tied updating RatingPercent instead but that doesn't work either. So how do I go about addressing this split personality rating?

Cheers,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Hi Hayo,

This is a bit of a mess.  There seem to be a couple of problems here.

First, the namespace seems to be different than what I have seen.  The group name for the known tags is XMP-Microsoft, not XMP-MicrosoftPhoto_1_.

Second, the XMP Microsoft Rating tag is not defined.

A tag must be defined to be able to write it.  Either of the above two problems would prevent writing of the tag.

Do you know what software wrote this tag?  Can you post the raw XMP (the output from exiftool -xmp -b FILE)?

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

Hayo Baan

Interesting :o

It's Nikon Capture NX2 that wrote the tag. I normally only edit my metadata with PhotoMechanic, but I guess I sometimes have accidentally touched some files in NX2. I'm now trying to get rid of the erroneous/confusing info NX2 wrote...

Here's the exact output of the command exiftool -xmp -b 5star.nef | pbcopy (yes, including all the empty lines...)
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.1.2">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"
    xmlns:MicrosoftPhoto_1_="http://ns.microsoft.com/photo/1.0/"
    xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
    xmlns:xmpRights="http://ns.adobe.com/xap/1.0/rights/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:photomechanic="http://ns.camerabits.com/photomechanic/1.0/"
    xmlns:xmp="http://ns.adobe.com/xap/1.0/"
    xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
   Iptc4xmpCore:CountryCode="DEU"
   Iptc4xmpCore:Location="Nationalparkzentrum Lusen"
   MicrosoftPhoto_1_:Rating="99"
   photoshop:City="Nationalpark Bayerischer Wald"
   photoshop:State="Bayern"
   photoshop:Country="Germany"
   photoshop:AuthorsPosition="Photographer"
   photoshop:Instructions="Please contact info@hayobaan.nl"
   photoshop:DateCreated="2012-05-19T17:15:39+02:00"
   xmpRights:Marked="True"
   xmpRights:WebStatement="http://www.hayobaan.nl"
   photomechanic:ColorClass="0"
   photomechanic:Tagged="False"
   photomechanic:Prefs="0:0:3:000550"
   photomechanic:PMVersion="PM5"
   xmp:Rating="3"
   aux:ImageNumber="550">
   <Iptc4xmpCore:CreatorContactInfo
    Iptc4xmpCore:CiAdrExtadr="Hayo Baan – Photography&#xA;Prins Bernhardweg 14"
    Iptc4xmpCore:CiAdrCity="Kockengen"
    Iptc4xmpCore:CiAdrRegion="Utrecht"
    Iptc4xmpCore:CiAdrPcode="3628 BM"
    Iptc4xmpCore:CiAdrCtry="The Netherlands"
    Iptc4xmpCore:CiTelWork="+31 6 12308489"
    Iptc4xmpCore:CiEmailWork="info@hayobaan.nl"
    Iptc4xmpCore:CiUrlWork="http://www.hayobaan.nl"/>
   <xmpRights:UsageTerms>
    <rdf:Alt>
     <rdf:li xml:lang="x-default">All Rights Reserved.</rdf:li>
    </rdf:Alt>
   </xmpRights:UsageTerms>
   <dc:subject>
    <rdf:Bag>
     <rdf:li>European Wildcat (Felis silvestris silvestris)</rdf:li>
    </rdf:Bag>
   </dc:subject>
   <dc:description>
    <rdf:Alt>
     <rdf:li xml:lang="x-default">European Wildcat kitten looking over a rock</rdf:li>
    </rdf:Alt>
   </dc:description>
   <dc:creator>
    <rdf:Seq>
     <rdf:li>Hayo Baan</rdf:li>
    </rdf:Seq>
   </dc:creator>
   <dc:rights>
    <rdf:Alt>
     <rdf:li xml:lang="x-default">© Hayo Baan – Photography. All Rights Reserved.</rdf:li>
    </rdf:Alt>
   </dc:rights>
  </rdf:Description>
</rdf:RDF>
</x:xmpmeta>
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                                   
                                                                                     
<?xpacket end="w"?>
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Ah.  There is only a single problem in this XMP.  NX2 is using the wrong namespace prefix.  They have written

http://ns.microsoft.com/photo/1.0/

when it should be

http://ns.microsoft.com/photo/1.0

A small difference, but significant.  You should send them a bug report.

If you fix this, then ExifTool will recognize the Microsoft tags and allow you to write RatingPercent.

The spaces at the end of the XMP are recommended by the specification.

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

Hayo Baan

#4
Hi Phil,

Ah, right, however, getting Nikon to fix their product is not going to happen in this case. Not only is Nikon known not to be too responsive in similar cases, they have now basically abandoned NX2 for their new product NX-D (which really is a downgrade, enough to get me off their software altogether and switch to DNG and Adobe...)

Anyway, I'm stuck with these erroneous entries and it would be great if ExifTool could fix them. As you say it's only a trailing /, so I hope it shouldn't be too hard to work around it in ExifTool?
Looking into XMP.pm, I can actually see that most uris have a trailing /, so perhaps it would be a good idea to parse the uri and always have it with the / appended (at least internally)? Or somehow have the code not care, or could we simply add it to the %nsURI hash, or...

Added: NX2 really is a badly behaving app; playing with setting the rating (and label), I sometimes was able to get rid of the XMP:XMP-MicrosoftPhoto_1_:Rating tag, only to be confronted with a different (and imo badly formed) XMP tag: XMP:XMP-xmp:Rating with a value of - (a dash). This one at least is deletable.

The problem though is getting NX2 to consistently create it (as that would be a workaround for my problem) instead of the MicrosoftPhoto tag. So far I have not succeeded in doing that  :-X

Thanks,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Hi Hayo,

I really hate having to patch ExifTool for problems in other software.  The XMP code already contains a number of ugly patches due to Microsoft inadequacies. :(

I have looked, and patching this problem is not as simple as it sounds, but I will see what I can do when I get a chance.

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

Hayo Baan

Yeah, it would be great if everyone conformed to the standards. But alas, they don't :(

I would appreciate it if you could fine a good way to deal with the issue. Personally, I would be helped with just a means of getting rid of the tag, even outside of the normal ExifTool code (though that likely wouldn't be of help to others using NX2 for rating).

If you need any input files, just let me know :)
Hayo Baan – Photography
Web: www.hayobaan.nl

Hayo Baan

#7
Phil, I tried some things and have found an (albeit clunky) way to get rid of the erroneous rating tag:

for f in BADFILES; do
  exiftool -b -XMP "$f" | perl -n -E 'print if ! m#xmlns:MicrosoftPhoto_1_=|MicrosoftPhoto_1_:#' > xmp
  exiftool -tagsFromFile xmp -XMP "$f"
done


Do you see any danger in doing it this way (i.e., is writing the complete XMP tag from a txt file, safe?)

Add1 Oh, I also tried to simply remove the trailing / from the xmlns specification line, but that didn't seem to work; the Rating tag now didn't show up at all which is kinda strange, not?
Add2 Ah, I guess that's because you don't know about the Rating tag in XMP:XMP-microsoft. When I changed it to RatingPercent, it did show up :)

Cheers,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Hi Hayo,

Just removing the MicrosoftPhoto namespace technically results in invalid XMP.

I was confused earlier (and you may be confused now too) because ExifTool renames the XMP-Microsoft "rating" to "RatingPercent" when it is properly identified.  This is done to avoid a name conflict with other Rating tags.

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

Hayo Baan

Hi Phil,

Now you got me a bit confused indeed  ;)

Quote from: Phil Harvey on June 21, 2014, 08:59:06 PM
Just removing the MicrosoftPhoto namespace technically results in invalid XMP.

I don't fully understand why removing any mention to this namespace would invalidate the xmp; the MicrosoftPhoto namespace isn't available in my "clean" xmp files either. Note that I removed both the namespace declaration (any line with mlns:MicrosoftPhoto_1_) as well as any entry in that namespace (any line with MicrosoftPhoto_1_:). In the 10 (only!) affected files, this only removed two lines by the way.
I just compared the xmp of the file with the ms stuff removed and one where I first corrected the trailing / (see below) and then removed the mircosoft xmp tags using exiftool '-XMP:XMP-microsoft:*'=. In both cases the xmp was exactly the same so I think the removal of the ms stuff the way I did it was just fine :-)

Quote from: Phil Harvey on June 21, 2014, 08:59:06 PM
I was confused earlier (and you may be confused now too) because ExifTool renames the XMP-Microsoft "rating" to "RatingPercent" when it is properly identified.  This is done to avoid a name conflict with other Rating tags.

Ah right, in my testing I forgot to look for RatingPercent (or Rating*), I see it indeed finds the rating percent now:for f in BADFILES; do exiftool -b -XMP "$f" | perl -n -E '$_ =~ s#http://ns.microsoft.com/photo/1.0/#http://ns.microsoft.com/photo/1.0#; print' > xmp; exiftool -P -tagsFromFile xmp -XMP "$f"; done
Output:exiftool -a -G0:1 -'Rating*' BADFILE
[XMP:XMP-microsoft] Rating Percent              : 25
[XMP:XMP-xmp]   Rating                          : 2

Together with the removal of the MS tags using exiftool '-XMP:XMP-microsoft:*'=, this would have then been another way to deal with the problem.

Anyway, it seems I now have gotten rid of the badly formed MS stuff completely :-)
Though others will likely suffer from this issue too (and probably to a bigger extent as I normally did not rate images in NX2, and others may have), it perhaps isn't too big an issue to change your code for (besides, there's an easy piece of command-line to fix it).

Thanks for all your time on this :)
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Hi Hayo,

Quote from: HayoBaan on June 22, 2014, 04:21:48 AM
I don't fully understand why removing any mention to this namespace would invalidate the xmp;

Ah, sorry.  I thought you were just removing the namespace definition.  I see now you were also removing the associated properties.  This will work for this specific formatting of XMP.

QuoteThough others will likely suffer from this issue too (and probably to a bigger extent as I normally did not rate images in NX2, and others may have), it perhaps isn't too big an issue to change your code for (besides, there's an easy piece of command-line to fix it).

I have done some work on this and added a patch that will issue a warning and fix incorrect URI's 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 ($).

Hayo Baan

Quote from: Phil Harvey on June 22, 2014, 07:01:50 AM
I have done some work on this and added a patch that will issue a warning and fix incorrect URI's like this.

Wow, very nice Phil.  8) Hope it wasn't too much hassle.

Thanks again for everything you've done :)

Cheers,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl