| 111 | |
| 112 | // ***************************************************************************** |
| 113 | void testCase(const std::string& file1, const std::string& file2, const std::string& thumb, const std::string& key, |
| 114 | const std::string& value) { |
| 115 | ExifKey ek(key); |
| 116 | |
| 117 | // Open first image |
| 118 | auto image1 = ImageFactory::open(file1); |
| 119 | |
| 120 | // Load existing metadata |
| 121 | std::cerr << "---> Reading file " << file1 << "\n"; |
| 122 | image1->readMetadata(); |
| 123 | |
| 124 | Exiv2::ExifData& ed1 = image1->exifData(); |
| 125 | std::cerr << "---> Modifying Exif data\n"; |
| 126 | auto pos = ed1.findKey(ek); |
| 127 | if (pos == ed1.end()) { |
| 128 | throw Error(ErrorCode::kerErrorMessage, "Metadatum with key = " + ek.key() + " not found"); |
| 129 | } |
| 130 | pos->setValue(value); |
| 131 | |
| 132 | // Open second image |
| 133 | auto image2 = ImageFactory::open(file2); |
| 134 | |
| 135 | image2->setExifData(image1->exifData()); |
| 136 | |
| 137 | std::cerr << "---> Writing Exif data to file " << file2 << "\n"; |
| 138 | image2->writeMetadata(); |
| 139 | |
| 140 | std::cerr << "---> Reading file " << file2 << "\n"; |
| 141 | image2->readMetadata(); |
| 142 | |
| 143 | Exiv2::ExifData& ed2 = image2->exifData(); |
| 144 | exifPrint(ed2); |
| 145 | |
| 146 | std::cerr << "---> Writing Exif thumbnail to file " << thumb << ".*\n"; |
| 147 | ExifThumbC et2(ed2); |
| 148 | auto s = et2.writeFile(thumb); |
| 149 | if (s == 0) |
| 150 | std::cerr << "---> Failed to write to file " << thumb << ".*\n"; |
| 151 | } |
| 152 | |
| 153 | // ***************************************************************************** |
| 154 |
no test coverage detected