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.
exiv2/src/exiftest.cpp

74 lines
2.1 KiB
C++

22 years ago
// ***************************************************************** -*- C++ -*-
/*
Abstract : This is playground code, do what you want with it.
22 years ago
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
Version : $Name: $ $Revision: 1.9 $
22 years ago
*/
// *****************************************************************************
// included header files
#include "exif.hpp"
22 years ago
#include <iostream>
#include <iomanip>
22 years ago
22 years ago
// *****************************************************************************
// local declarations
using namespace Exif;
22 years ago
void exifPrint(const ExifData& exifData);
22 years ago
// *****************************************************************************
// Main
int main(int argc, char* const argv[])
22 years ago
try {
ExifData exifData;
if (argc != 2) {
std::cout << "Usage: exiftest file\n";
return 1;
}
22 years ago
int rc = exifData.read(argv[1]);
if (rc) throw Error("Reading Exif data failed");
22 years ago
exifPrint(exifData);
exifData.writeThumbnail("thumb");
22 years ago
return rc;
22 years ago
}
22 years ago
catch (Error& e) {
std::cout << "Caught Exif exception '" << e << "'\n";
return 1;
}
// *****************************************************************************
// local definitions
22 years ago
void exifPrint(const ExifData& exifData)
{
ExifData::const_iterator beg = exifData.begin();
ExifData::const_iterator end = exifData.end();
ExifData::const_iterator i = beg;
for (; i != end; ++i) {
std::cout << "0x"
<< std::hex << std::setw(4) << std::setfill('0') << std::right
<< i->tag() << " "
<< std::setw(27) << std::setfill(' ') << std::left
<< i->tagName() << " "
<< std::setw(17) << std::setfill(' ') << std::left
<< i->typeName() << " "
<< std::dec << std::setw(3)
<< std::setfill(' ') << std::right
<< i->count() << " "
<< std::dec << i->value()
// << " | " << i->key()
22 years ago
<< " | " << i->ifdName()
<< " | " << i->ifdIdx()
<< "\n";
}
}