Incorrect ordering of xmp struct tags with double digit indexes
OS: Windows 10 Home, 64-bit. gexiv2 version: mingw64/mingw-w64-x86_64-gexiv2 0.12.1-1 and current master branch exiv2 version: mingw64/mingw-w64-x86_64-exiv2 0.27.3-1
For GIMP I am looking into some metadata related bugs. One of them concerns this image: gimp#1485 (comment 222132)
We load xmp tags using gexiv2_metadata_get_xmp_tags
and after possibly adding and/or removing tags we save it with gexiv2_metadata_save_file
.
This fails on the image in the above mentioned bug note because it has History tags with indexes going higher than 9. The double digit index tags get sorted before index 1 which causes saving of xmp to fail. The console lists the following problems:
** (file-jpeg:41256): CRITICAL **: 14:30:46.865: XMP Toolkit error 102: Specified property does not exist
** (file-jpeg:41256): CRITICAL **: 14:30:46.865: Failed to encode XMP metadata.
Looking at gexiv2_metadata_get_xmp_tags
I see that it calls xmp_data.sortByKey ();
When I comment out this line saving works though I do not know enough of the metadata internals to say if that always holds true.
Now if I see it correctly the sorting routine is defined in exiv2 but if sorting is not essential it might be better to make sorting optional or completely remove it and leave it to the users of your library to decide if they want the tags sorted or not.