Sample program to print Exif data from an image.
 
#include <exiv2/exiv2.hpp>
#include <iostream>
#include <iomanip>
#include <cassert>
 
#if defined(EXV_UNICODE_PATH) && defined(__MINGW__)
#undef  EXV_UNICODE_PATH
#endif
 
#ifdef  EXV_UNICODE_PATH
#define _tchar      wchar_t
#define _tstrcmp    wcscmp
#define _t(s)       L##s
#define _tcout      wcout
#define _tmain      wmain
#else
#define _tchar      char
#define _tstrcmp    strcmp
#define _t(s)       s
#define _tcout      cout
#define _tmain      main
#endif
 
int _tmain(int argc, _tchar* const argv[])
try {
#ifdef EXV_ENABLE_BMFF
    Exiv2::enableBMFF();
#endif
 
    const _tchar* prog = argv[0];
    const _tchar* file = argv[1];
 
    if (argc != 2) {
        std::_tcout << _t("Usage: ") << prog << _t(" [ path | --version | --version-test ]") << std::endl;
        return 1;
    }
 
    if ( _tstrcmp(file,_t("--version")) == 0 ) {
        exv_grep_keys_t keys;
        return 0;
    } else if ( _tstrcmp(file,_t("--version-test")) == 0 ) {
        
        
        std::cout << "EXV_PACKAGE_VERSION             " << EXV_PACKAGE_VERSION             << std::endl
                  << 
"strlen(Exiv2::version())        " << ::strlen(
Exiv2::version())      << std::endl
 
                  ;
 
        
        
        
        #if EXIV2_TEST_VERSION(0,15,0)
              std::cout << "Available Exiv2 version is equal to or greater than 0.13\n";
            } else {
              std::cout << "Installed Exiv2 version is less than 0.13\n";
            }
        #else
              std::cout << "Compile-time Exiv2 version doesn't have Exiv2::testVersion()\n";
        #endif
        return 0;
    }
 
    assert(image.get() != 0);
    image->readMetadata();
 
        std::string error("No Exif data found in file");
    }
 
        const char* tn = i->typeName();
        std::cout << std::setw(44) << std::setfill(' ') << std::left
                  << i->key() << " "
                  << "0x" << std::setw(4) << std::setfill('0') << std::right
                  << std::hex << i->tag() << " "
                  << std::setw(9) << std::setfill(' ') << std::left
                  << (tn ? tn : "Unknown") << " "
                  << std::dec << std::setw(3)
                  << std::setfill(' ') << std::right
                  << i->count() << "  "
                  << std::dec << i->toString()
                  << "\n";
    }
 
    return 0;
}
    std::cout << 
"Caught Exiv2 exception '" << e.
what() << 
"'\n";
 
    return -1;
}