Project

General

Profile

Bug #396 » test.cpp

Redmine Admin, 09 Nov 2004 23:33

 
1
// ***************************************************************** -*- C++ -*-
2
// *****************************************************************************
3

    
4
// included header files
5
#include "exif.hpp"
6
#include <iostream>
7
#include <iomanip>
8

    
9
using namespace Exiv2;
10

    
11
// *****************************************************************************
12
// Main
13
int main(int argc, char* const argv[])
14
try {
15
    if( argc != 2 ){
16
        std::cerr << "Usage: test file.jpg" << std::endl;
17
        return 1;
18
    }
19

    
20
    Exiv2::ExifData exifData;
21
    exifData.read(argv[1]);
22

    
23
    ExifKey exifKey("Exif.Image.ImageDescription");
24

    
25
    Value::AutoPtr value = Value::create(asciiString);
26
    value->read("I don't really know");
27

    
28
    ExifData::iterator iter = exifData.findKey(exifKey);
29
    if (iter != exifData.end()) {
30
        iter->setValue(value.get());
31
    }
32
    else {
33
        exifData.add(exifKey, value.get());
34
    }
35

    
36
    exifData.write(argv[1]);
37

    
38
    return 0;
39
}
40
catch (Exiv2::Error& e) {
41
    std::cout << "Caught Exiv2 exception '" << e << "'\n";
42
    return -1;
43
}
(2-2/2)