1
// ***************************************************************** -*- C++ -*-
2
// iptceasy.cpp, $Rev: 560 $
3
// The quickest way to access, set or modify Iptc metadata.
11
int main(int argc, char* const argv[])
14
std::cout << "Usage: " << argv[0] << " file\n";
17
std::string file(argv[1]);
19
Exiv2::IptcData iptcData;
21
iptcData["Iptc.Application2.Headline"] = "The headline I am";
22
iptcData["Iptc.Application2.Keywords"] = "Yet another keyword";
23
iptcData["Iptc.Application2.DateCreated"] = "2004-8-3";
24
iptcData["Iptc.Application2.Urgency"] = uint16_t(1);
25
iptcData["Iptc.Envelope.ModelVersion"] = 42;
26
iptcData["Iptc.Envelope.TimeSent"] = "14:41:0-05:00";
27
iptcData["Iptc.Application2.RasterizedCaption"] = "230 42 34 2 90 84 23 146";
28
iptcData["Iptc.0x0009.0x0001"] = "Who am I?";
30
Exiv2::StringValue value;
32
iptcData["Iptc.Application2.Urgency"] = value;
34
std::cout << "Time sent: " << iptcData["Iptc.Envelope.TimeSent"] << "\n";
37
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(file);
38
assert (image.get() != 0);
40
// Set Iptc data and write it to the file
41
image->setIptcData(iptcData);
42
image->writeMetadata();
46
catch (Exiv2::AnyError& e) {
47
std::cout << "Caught Exiv2 exception '" << e << "'\n";