Main
| 9 | // ***************************************************************************** |
| 10 | // Main |
| 11 | int main(int argc, char* const argv[]) { |
| 12 | Exiv2::XmpParser::initialize(); |
| 13 | ::atexit(Exiv2::XmpParser::terminate); |
| 14 | |
| 15 | try { |
| 16 | if (argc != 2) { |
| 17 | std::cout << "Usage: " << argv[0] << " file\n"; |
| 18 | return EXIT_FAILURE; |
| 19 | } |
| 20 | std::string file(argv[1]); |
| 21 | |
| 22 | std::cout << "----- Some IFD0 tags\n"; |
| 23 | Exiv2::ExifData ed1; |
| 24 | ed1["Exif.Image.Model"] = "Test 1"; |
| 25 | |
| 26 | auto v1 = Exiv2::Value::create(Exiv2::unsignedShort); |
| 27 | v1->read("160 161 162 163"); |
| 28 | ed1.add(Exiv2::ExifKey("Exif.Image.SamplesPerPixel"), v1.get()); |
| 29 | |
| 30 | auto v2 = Exiv2::Value::create(Exiv2::signedLong); |
| 31 | v2->read("-2 -1 0 1"); |
| 32 | ed1.add(Exiv2::ExifKey("Exif.Image.XResolution"), v2.get()); |
| 33 | |
| 34 | auto v3 = Exiv2::Value::create(Exiv2::signedRational); |
| 35 | v3->read("-2/3 -1/3 0/3 1/3"); |
| 36 | ed1.add(Exiv2::ExifKey("Exif.Image.YResolution"), v3.get()); |
| 37 | |
| 38 | auto v4 = Exiv2::Value::create(Exiv2::undefined); |
| 39 | v4->read("255 254 253 252"); |
| 40 | ed1.add(Exiv2::ExifKey("Exif.Image.WhitePoint"), v4.get()); |
| 41 | |
| 42 | write(file, ed1); |
| 43 | print(file); |
| 44 | |
| 45 | std::cout << "\n----- One Exif tag\n"; |
| 46 | Exiv2::ExifData ed2; |
| 47 | ed2["Exif.Photo.DateTimeOriginal"] = "Test 2"; |
| 48 | write(file, ed2); |
| 49 | print(file); |
| 50 | |
| 51 | std::cout << "\n----- Canon MakerNote tags\n"; |
| 52 | Exiv2::ExifData edMn1; |
| 53 | edMn1["Exif.Image.Make"] = "Canon"; |
| 54 | edMn1["Exif.Image.Model"] = "Canon PowerShot S40"; |
| 55 | edMn1["Exif.Canon.0xabcd"] = "A Canon makernote tag"; |
| 56 | edMn1["Exif.CanonCs.0x0002"] = static_cast<uint16_t>(41); |
| 57 | edMn1["Exif.CanonSi.0x0005"] = static_cast<uint16_t>(42); |
| 58 | edMn1["Exif.CanonCf.0x0001"] = static_cast<uint16_t>(43); |
| 59 | edMn1["Exif.CanonPi.0x0001"] = static_cast<uint16_t>(44); |
| 60 | edMn1["Exif.CanonPa.0x0001"] = static_cast<uint16_t>(45); |
| 61 | write(file, edMn1); |
| 62 | print(file); |
| 63 | |
| 64 | std::cout << "\n----- Non-intrusive writing of special Canon MakerNote tags\n"; |
| 65 | auto image = Exiv2::ImageFactory::open(file); |
| 66 | image->readMetadata(); |
| 67 | |
| 68 | Exiv2::ExifData& rEd = image->exifData(); |
nothing calls this directly
no test coverage detected