metadata: try to be more robust when saving
Tentative fix for #89 (cherry picked from commit a8b53fef753c7a1146013feeb66be87c688b8631)
This commit is contained in:
committed by
Lawrence Lee
parent
700eeccb39
commit
6cec805774
@@ -1399,7 +1399,7 @@ bool ImageIO::saveMetadata(const Glib::ustring &fname) const
|
|||||||
// dst->writeMetadata();
|
// dst->writeMetadata();
|
||||||
} catch (const std::exception& exc) {
|
} catch (const std::exception& exc) {
|
||||||
std::cout << "EXIF ERROR: " << exc.what() << std::endl;
|
std::cout << "EXIF ERROR: " << exc.what() << std::endl;
|
||||||
return false;
|
//return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -238,7 +238,35 @@ void Exiv2Metadata::saveToImage(const Glib::ustring &path) const
|
|||||||
dst->exifData()["Exif.Image.Software"] = "RawTherapee " RTVERSION;
|
dst->exifData()["Exif.Image.Software"] = "RawTherapee " RTVERSION;
|
||||||
import_exif_pairs(dst->exifData());
|
import_exif_pairs(dst->exifData());
|
||||||
import_iptc_pairs(dst->iptcData());
|
import_iptc_pairs(dst->iptcData());
|
||||||
dst->writeMetadata();
|
bool xmp_tried = false;
|
||||||
|
bool iptc_tried = false;
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
try {
|
||||||
|
dst->writeMetadata();
|
||||||
|
return;
|
||||||
|
} catch (Exiv2::Error &exc) {
|
||||||
|
if (exc.code() == 37) {
|
||||||
|
std::string msg = exc.what();
|
||||||
|
if (msg.find("XMP") != std::string::npos &&
|
||||||
|
!dst->xmpData().empty()) {
|
||||||
|
dst->xmpData().clear();
|
||||||
|
if (!xmp_tried && merge_xmp_) {
|
||||||
|
do_merge_xmp(dst.get());
|
||||||
|
xmp_tried = true;
|
||||||
|
}
|
||||||
|
} else if (msg.find("IPTC") != std::string::npos &&
|
||||||
|
!dst->iptcData().empty()) {
|
||||||
|
dst->iptcData().clear();
|
||||||
|
if (!iptc_tried) {
|
||||||
|
import_iptc_pairs(dst->iptcData());
|
||||||
|
iptc_tried = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw exc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user