00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "image.hpp"
00015 #include "exif.hpp"
00016 #include <iostream>
00017 #include <iomanip>
00018 #include <cstring>
00019 #include <cassert>
00020
00021
00022
00023 int main(int argc, char* const argv[])
00024 try {
00025
00026 if (argc != 2) {
00027 std::cout << "Usage: " << argv[0] << " file\n";
00028 return 1;
00029 }
00030
00031 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]);
00032 assert (image.get() != 0);
00033 image->readMetadata();
00034 Exiv2::ExifData &exifData = image->exifData();
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 exifData["Exif.Photo.UserComment"]
00049 = "charset=\"Unicode\" An Unicode Exif comment added with Exiv2";
00050 exifData["Exif.Photo.UserComment"]
00051 = "charset=\"Undefined\" An undefined Exif comment added with Exiv2";
00052 exifData["Exif.Photo.UserComment"]
00053 = "Another undefined Exif comment added with Exiv2";
00054 exifData["Exif.Photo.UserComment"]
00055 = "charset=Ascii An ASCII Exif comment added with Exiv2";
00056
00057 std::cout << "Writing user comment '"
00058 << exifData["Exif.Photo.UserComment"]
00059 << "' back to the image\n";
00060
00061 image->writeMetadata();
00062
00063 return 0;
00064 }
00065 catch (Exiv2::AnyError& e) {
00066 std::cout << "Caught Exiv2 exception '" << e << "'\n";
00067 return -1;
00068 }