0

when I try to add XMP metadata to a file using exiv2 as library it just won't stick. After executing my code the file was modified, but has not changed in size and contains no XMP metadata. The following code is my testcase.

string fileName = "test.png";
vector<string> keyWords;
keyWords.push_back("keyword 1");
keyWords.push_back("keyword 2");
Exiv2::XmpParser::initialize();
image = Exiv2::ImageFactory::open(fileName);
assert(image.get() != 0);
assert(image->good());
image->readMetadata();
Exiv2::XmpData& xmpData = image->xmpData();
Exiv2::Value::AutoPtr subjects = Exiv2::Value::create(Exiv2::xmpBag);
for each (auto kw in keyWords)
    subjects->read(kw);
xmpData.add(Exiv2::XmpKey("Xmp.dc.subject"), subjects.get());
image->writeMetadata();

I tried the same using the precompiled command line tool which works.

exiv2 -v -k -m addxmp.txt mo test.png
File 1/1: test.png
Add Xmp.dc.subject "keyword1" (XmpBag)

I dug through the original source but found no difference. What is it that I do not see?

I'm running VS2019 on Windows 10 and this is a Cmake project which manages it's dependencies with vcpkg. exiv2 is installed via vcpkg.

  • I installed the package with vcpkg install exiv2:x64-windows. I just dug a bit deeper to find another package named exiv2[xmp], which is built with xmp-support. I suppose that explains my problem. Compiling takes a while. I'll get back in a moment. – Lord Helmchen Dec 14 '20 at 22:14

1 Answers1

0

If you use exiv2 libaries with vcpkg and need XMP support make sure to install it like this not forgetting the xmp in brackets...

vcpkg install exiv2[xmp]:x64-windows