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 <cassert>
00018
00019
00020
00021 int main(int argc, char* const argv[])
00022 try {
00023
00024 if (argc != 2) {
00025 std::cout << "Usage: " << argv[0] << " file\n";
00026 return 1;
00027 }
00028
00029 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]);
00030 assert (image.get() != 0);
00031 image->readMetadata();
00032 Exiv2::ExifData &exifData = image->exifData();
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 exifData["Exif.Photo.UserComment"]
00047 = "charset=\"Unicode\" An Unicode Exif comment added with Exiv2";
00048 exifData["Exif.Photo.UserComment"]
00049 = "charset=\"Undefined\" An undefined Exif comment added with Exiv2";
00050 exifData["Exif.Photo.UserComment"]
00051 = "Another undefined Exif comment added with Exiv2";
00052 exifData["Exif.Photo.UserComment"]
00053 = "charset=Ascii An ASCII Exif comment added with Exiv2";
00054
00055 std::cout << "Writing user comment '"
00056 << exifData["Exif.Photo.UserComment"]
00057 << "' back to the image\n";
00058
00059 image->writeMetadata();
00060
00061 return 0;
00062 }
00063 catch (Exiv2::AnyError& e) {
00064 std::cout << "Caught Exiv2 exception '" << e << "'\n";
00065 return -1;
00066 }