You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
// ***************************************************************** -*- C++ -*-
|
|
|
|
// iptcprint.cpp, $Rev$
|
|
|
|
// Sample program to print the Iptc metadata of an image
|
|
|
|
|
|
|
|
#include "iptc.hpp"
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
int main(int argc, char* const argv[])
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (argc != 2) {
|
|
|
|
std::cout << "Usage: " << argv[0] << " file\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Exiv2::IptcData iptcData;
|
|
|
|
int rc = iptcData.read(argv[1]);
|
|
|
|
if (rc) {
|
|
|
|
std::string error = Exiv2::IptcData::strError(rc, argv[1]);
|
|
|
|
throw Exiv2::Error(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
Exiv2::IptcData::iterator end = iptcData.end();
|
|
|
|
for (Exiv2::IptcData::iterator i = iptcData.begin(); i != end; ++i) {
|
|
|
|
std::cout << std::setw(40) << std::setfill(' ') << std::left
|
|
|
|
<< i->key() << " "
|
|
|
|
<< "0x" << std::setw(4) << std::setfill('0') << std::right
|
|
|
|
<< std::hex << i->tag() << " "
|
|
|
|
<< std::dec << i->value()
|
|
|
|
<< "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
catch (Exiv2::Error& e) {
|
|
|
|
std::cout << "Caught Exiv2 exception '" << e << "'\n";
|
|
|
|
return -1;
|
|
|
|
}
|