#include <exiv2/exiv2.hpp>
#include <iostream>
int main(int argc, char* const argv[]) try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return EXIT_FAILURE;
}
image->readMetadata();
std::string error(argv[1]);
error += ": No IPTC data found in the file";
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
auto end = iptcData.
end();
for (
auto md = iptcData.
begin(); md != end; ++md) {
std::cout << std::setw(44) << std::setfill(' ') << std::left << md->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << md->tag() << " " << std::setw(9)
<< std::setfill(' ') << std::left << md->typeName() << " " << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << md->count() << " " << std::dec << md->value() << std::endl;
}
return EXIT_SUCCESS;
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return EXIT_FAILURE;
} catch (const std::exception& e) {
std::cout <<
"Caught exception: '" << e.
what() <<
"'\n";
return EXIT_FAILURE;
}
Simple error class used for exceptions. An output operator is provided to print errors to a stream.
Definition: error.hpp:235
const char * what() const noexcept override
Return the error message as a C-string. The pointer returned by what() is valid only as long as the B...
static Image::UniquePtr open(const std::string &path, bool useCurl=true)
Create an Image subclass of the appropriate type by reading the specified file. Image type is derived...
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition: iptc.hpp:153
iterator begin()
Begin of the metadata.
Definition: iptc.hpp:206
bool empty() const
Return true if there is no IPTC metadata.
Definition: iptc.hpp:246
iterator end()
End of the metadata.
Definition: iptc.hpp:210
static void terminate()
Terminate the XMP Toolkit and unregister custom namespaces.
static bool initialize(XmpParser::XmpLockFct xmpLockFct=nullptr, void *pLockData=nullptr)
Initialize the XMP Toolkit.