SUMMARY MWG mwg-rs:AppliedToDimensions XMP tag is not included when writting Face metada to file. These values are important in determining if the face regions are valid for the image. STEPS TO REPRODUCE 1. Using a photo with a face, scan for face. 2. Add name details to face region. 3. Write face metadata to image file. OBSERVED RESULT Using a metadata extraction tool such as exiftool, extract XMP. Example: exiftool <filename> -xmp -b > output.xml Face data is added within mwg-rs:Regions mwg-rs:AppliedToDimensions XMP tag with image height and width dimensions are not included. EXPECTED RESULT - Per MWG (Metadata Working Group) Guidelines for Handling Image Metadata version 2.0 page 53 - the mwg-rs:AppliedToDimensions field should contain "Width and height of the image at the time of processing when storing image region metadata." - Why is this important/useful? When an image is cropped, rotated and/or resized using an application which does not re-adjust the MWG file regions the regions risk being offset. An application can compare the recorded mwg-rs:AppliedToDimensions with the actual image dimensions to determine if the face regions are valid or not. - In the event that the AppliedToDimensions and actual image dimensions do not match, Digikam may choose to ignore/invalidate the face regions so they can be re-applied. - In the event an image is resized, cropped or rotated, Digikam should adjust the image regions accordingly and reset the AppliedToDimensions value. - Another risk is that an application which does read MWG regions may ignore the face regions added by Digikam, based on the assumption that these are invalid or do not adhere to the MWG guidelines. Refer to Page 55: “Applied To” State Since the file may be modified by actors that are either non-compliant to this guidance or choose not to participate in image region metadata, it is critical to retain information about what the state of the image was when the region was specified. A Creator MUST store the region “applied to” width and height. A Changer MUST update the “applied to” value upon a resize, crop, or physical rotation in order to ensure that the region information is still valid for the new state of the file. In the case of a crop or physical rotation, a Changer MUST also update the region coordinates so as to further ensure that the region information remains valid. A Changer SHOULD remove region information for regions that are no longer applicable (e.g. a region that was orphaned due to a crop or rotation operation). A Consumer MUST validate the current state of the image and compare this against the “applied to” state to ensure that the region information is up-to-date. The information specified in the region MUST be validated to ensure that the data is applicable to the current state of the file. In the case where the “applied to” size and actual image size differ, if the ratio is significantly different a Consumer SHOULD ignore the region. Otherwise a Consumer or Changer MAY update the region metadata as though the image were scaled to the new dimensions. SOFTWARE/OS VERSIONS Windows: 10 macOS: Linux/KDE Plasma: (available in About System) KDE Plasma Version: KDE Frameworks Version: Qt Version: ADDITIONAL INFORMATION References: https://www.exiv2.org/tags-xmp-mwg-rs.html
Created attachment 135332 [details] Example Files Adding example files: 1. Einstein.jpg is a 800x1050 image with MWG regions applied. AppliedTo dimensions are h=1050 and w=800. 2. Einstein_cropped.jpg is Einstein.jpg cropped to 534x700 with an application which does not correct the AppliedTo settings. AppliedTo remain at h=1050 and w=800, thus indicating an invalid MWG. Suggested Digikam behavior when an invalid MWG is encountered: 1. Read the names of the MWG face tags and add them to People tags- as the face names may still be valid information and should not be lost on crop. 2. Do not apply the face regions encountered in the file metadata, as they are likely invalid. 3. Re-apply face detection/recognition so that the user can correct the face region.
This report is open for 7.1.0 release. It can be reproduced with current 7.2.0 pre release ? https://files.kde.org/digikam/ Gilles Caulier
Yes, I can reproduce it on 7.2.0-rc (ffbcb5f3)
Created attachment 135563 [details] Sample - Expected XMP metadata tag Adding sample XMP file on the expected MWG XML structure. XMP extracted from jpg using exiftool and created mwg from MS People Tag using method described here: https://jmoliver.wordpress.com/2017/02/19/converting-and-exporting-windows-photo-gallery-people-tags/ Note "AppliedToDimensions" tag: <mwg-rs:AppliedToDimensions rdf:parseType='Resource'> <stDim:h>1050</stDim:h> <stDim:unit>pixel</stDim:unit> <stDim:w>800</stDim:w> </mwg-rs:AppliedToDimensions>
Since Exiftool support has been introduced to Digikam in 7.3.0, could Exiftool be used to read as well as write these tags to file when Face Regions are edited? Exiftool Ref: https://exiftool.org/TagNames/MWG.html#Regions
yes, sure ExifTool can used for this task, if Exiv2 is not able to do it as well. The digiKam Exiftool CC+/Qt interface that we write in digiKam core is designed to be extendable for this kind of use. Gilles Caulier
Exiv2 already supports the AppliedToDimensions tag. Maik
*** Bug 445440 has been marked as a duplicate of this bug. ***
As I described in Bug 445440, this issue also prevents the correct import of face tags into Lightroom. Because Lightroom considers mwg-rs without dimensions information invalid. I've made many tries and that's the only reason.
Git commit 8f9bb6617460fd337ab2657b1c76a3e5421fa448 by Maik Qualmann. Committed on 14/11/2021 at 13:15. Pushed by mqualmann into branch 'master'. add write mwg-rs:AppliedToDimensions XMP tag structure Note: digiKam itself still ignores AppliedToDimensions when importing. Related: bug 445440 FIXED-IN: 7.4.0 M +2 -2 NEWS M +5 -3 core/libs/fileactionmanager/metadatahub.cpp M +1 -1 core/libs/metadataengine/dmetadata/dmetadata.h M +34 -2 core/libs/metadataengine/dmetadata/dmetadata_faces.cpp https://invent.kde.org/graphics/digikam/commit/8f9bb6617460fd337ab2657b1c76a3e5421fa448
This is great news! Lack of this tag had me worried for proper support of MWG Face Regions. However, how will Digikam manage images with invalid AppliedToDimensions? When opening the bug I stated: "In the event that the AppliedToDimensions and actual image dimensions do not match, Digikam may choose to ignore/invalidate the face regions so they can be re-applied." What I mean with that statement is that if an image is cropped using another application which cannot adjust the face regions accordingly, the existing face regions should be ignored but the People's names should be respected so that it can be easier to re-tag them later within Digikam.
digiKam will definitely ignore the absence of the AppliedToDimensions tag. If a user had to restore their database, all of the face regions made so far would not be restored. That's why I find the Lightroom behavior very strange. If the AppliedToDimensions tag is available, we can include it, I will implement it soon. At the moment I don't know whether the image orientation has to be ignored with the AppliedToDimensions tag and how other programs behave. Since we still do not know the orientation for which the face regions were saved. Maik