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.
33 lines
901 B
C++
33 lines
901 B
C++
17 years ago
|
// ***************************************************************** -*- C++ -*-
|
||
8 years ago
|
// xmpdump.cpp
|
||
17 years ago
|
// Sample program to dump the XMP packet of an image
|
||
|
|
||
|
#include <cassert>
|
||
7 years ago
|
#include <iostream>
|
||
|
#include <string>
|
||
|
#include "image.hpp"
|
||
17 years ago
|
|
||
7 years ago
|
int main(int argc, char* const argv[]) try {
|
||
17 years ago
|
if (argc != 2) {
|
||
|
std::cout << "Usage: " << argv[0] << " file\n";
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]);
|
||
|
assert(image.get() != 0);
|
||
|
image->readMetadata();
|
||
|
|
||
|
const std::string& xmpPacket = image->xmpPacket();
|
||
|
if (xmpPacket.empty()) {
|
||
|
std::string error(argv[1]);
|
||
|
error += ": No XMP packet found in the file";
|
||
7 years ago
|
throw Exiv2::Error(Exiv2::kerErrorMessage, error);
|
||
17 years ago
|
}
|
||
|
std::cout << xmpPacket << "\n";
|
||
|
|
||
|
return 0;
|
||
7 years ago
|
} catch (Exiv2::AnyError& e) {
|
||
17 years ago
|
std::cout << "Caught Exiv2 exception '" << e << "'\n";
|
||
|
return -1;
|
||
|
}
|