imageio: do not fail in saving an image if no metadata is available
(cherry picked from commit 86d48be88b6f9fe36e5e25185ec4fda7696efc25)
This commit is contained in:
parent
e205ff86cc
commit
ea3cf2fe8f
@ -41,6 +41,7 @@
|
||||
#include "iccjpeg.h"
|
||||
#include "color.h"
|
||||
#include "imagedata.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "jpeg.h"
|
||||
|
||||
@ -48,6 +49,8 @@ using namespace std;
|
||||
using namespace rtengine;
|
||||
using namespace rtengine::procparams;
|
||||
|
||||
namespace rtengine { extern const Settings *settings; }
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -1355,8 +1358,18 @@ bool ImageIO::saveMetadata(const Glib::ustring &fname) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool has_meta = true;
|
||||
try {
|
||||
metadataInfo.load();
|
||||
} catch (const std::exception& exc) {
|
||||
if (settings->verbose) {
|
||||
std::cout << "EXIF LOAD ERROR: " << exc.what() << std::endl;
|
||||
}
|
||||
has_meta = false;
|
||||
}
|
||||
|
||||
if (has_meta) {
|
||||
try {
|
||||
metadataInfo.saveToImage(fname);
|
||||
// auto src = open_exiv2(metadataInfo.filename());
|
||||
// auto dst = open_exiv2(fname);
|
||||
@ -1384,9 +1397,11 @@ bool ImageIO::saveMetadata(const Glib::ustring &fname) const
|
||||
// }
|
||||
// }
|
||||
// dst->writeMetadata();
|
||||
return true;
|
||||
} catch (const std::exception& exc) {
|
||||
std::cout << "EXIF ERROR: " << exc.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user