fixed bugs in metadata saving
(cherry picked from commit 880b1d3d865a7820051cf3023cc58802daca28b0)
This commit is contained in:
committed by
Lawrence Lee
parent
1a771fa211
commit
a4b0801646
@@ -1789,6 +1789,11 @@ PREFERENCES_MENUGROUPLABEL;Group "Color label"
|
||||
PREFERENCES_MENUGROUPPROFILEOPERATIONS;Group "Processing profile operations"
|
||||
PREFERENCES_MENUGROUPRANK;Group "Rank"
|
||||
PREFERENCES_MENUOPTIONS;Context Menu Options
|
||||
PREFERENCES_METADATA;Metadata
|
||||
PREFERENCES_METADATA_SYNC;Metadata synchronization with XMP sidecars
|
||||
PREFERENCES_METADATA_SYNC_NONE;Off
|
||||
PREFERENCES_METADATA_SYNC_READ;Read only
|
||||
PREFERENCES_METADATA_SYNC_READWRITE;Bidirectional
|
||||
PREFERENCES_MONINTENT;Default rendering intent
|
||||
PREFERENCES_MONITOR;Monitor
|
||||
PREFERENCES_MONPROFILE;Default color profile
|
||||
@@ -1864,6 +1869,9 @@ PREFERENCES_TP_LABEL;Tool panel:
|
||||
PREFERENCES_TP_VSCROLLBAR;Hide vertical scrollbar
|
||||
PREFERENCES_USEBUNDLEDPROFILES;Use bundled profiles
|
||||
PREFERENCES_WORKFLOW;Layout
|
||||
PREFERENCES_XMP_SIDECAR_MODE;XMP sidecar style
|
||||
PREFERENCES_XMP_SIDECAR_MODE_STD;Standard (FILENAME.xmp for FILENAME.ext)
|
||||
PREFERENCES_XMP_SIDECAR_MODE_EXT;Darktable-like (FILENAME.ext.xmp for FILENAME.ext)
|
||||
PREFERENCES_ZOOMONSCROLL;Zoom images by scrolling
|
||||
PROFILEPANEL_COPYPPASTE;Parameters to copy
|
||||
PROFILEPANEL_GLOBALPROFILES;Bundled profiles
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "profilestore.h"
|
||||
#include "../rtgui/threadutils.h"
|
||||
#include "rtlensfun.h"
|
||||
#include "metadata.h"
|
||||
#include "procparams.h"
|
||||
|
||||
namespace rtengine
|
||||
@@ -103,6 +104,8 @@ int init (const Settings* s, const Glib::ustring& baseDir, const Glib::ustring&
|
||||
}
|
||||
|
||||
Color::init ();
|
||||
Exiv2Metadata::init();
|
||||
|
||||
delete lcmsMutex;
|
||||
lcmsMutex = new MyMutex;
|
||||
fftwMutex = new MyMutex;
|
||||
@@ -111,6 +114,7 @@ int init (const Settings* s, const Glib::ustring& baseDir, const Glib::ustring&
|
||||
|
||||
void cleanup ()
|
||||
{
|
||||
Exiv2Metadata::cleanup();
|
||||
ProcParams::cleanup ();
|
||||
Color::cleanup ();
|
||||
RawImageSource::cleanup ();
|
||||
|
@@ -20,6 +20,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "metadata.h"
|
||||
#include "settings.h"
|
||||
#include "../rtgui/version.h"
|
||||
@@ -65,7 +67,7 @@ Exiv2Metadata::Exiv2Metadata():
|
||||
|
||||
|
||||
Exiv2Metadata::Exiv2Metadata(const Glib::ustring &path):
|
||||
src_(""),
|
||||
src_(path),
|
||||
merge_xmp_(settings->metadata_xmp_sync != Settings::MetadataXmpSync::NONE),
|
||||
image_(nullptr),
|
||||
exif_(new rtengine::procparams::ExifPairs),
|
||||
@@ -154,20 +156,27 @@ void Exiv2Metadata::setIptc(const rtengine::procparams::IPTCPairs &iptc)
|
||||
|
||||
void Exiv2Metadata::do_merge_xmp(Exiv2::Image *dst) const
|
||||
{
|
||||
auto xmp = getXmpSidecar(src_);
|
||||
Exiv2::ExifData exif;
|
||||
Exiv2::IptcData iptc;
|
||||
Exiv2::moveXmpToExif(xmp, exif);
|
||||
Exiv2::moveXmpToIptc(xmp, iptc);
|
||||
try {
|
||||
auto xmp = getXmpSidecar(src_);
|
||||
Exiv2::ExifData exif;
|
||||
Exiv2::IptcData iptc;
|
||||
Exiv2::moveXmpToIptc(xmp, iptc);
|
||||
Exiv2::moveXmpToExif(xmp, exif);
|
||||
|
||||
for (auto &datum : exif) {
|
||||
dst->exifData()[datum.key()] = datum;
|
||||
}
|
||||
for (auto &datum : iptc) {
|
||||
dst->iptcData()[datum.key()] = datum;
|
||||
}
|
||||
for (auto &datum : xmp) {
|
||||
dst->xmpData()[datum.key()] = datum;
|
||||
for (auto &datum : exif) {
|
||||
dst->exifData()[datum.key()] = datum;
|
||||
}
|
||||
for (auto &datum : iptc) {
|
||||
dst->iptcData()[datum.key()] = datum;
|
||||
}
|
||||
for (auto &datum : xmp) {
|
||||
dst->xmpData()[datum.key()] = datum;
|
||||
}
|
||||
} catch (Exiv2::AnyError &exc) {
|
||||
if (settings->verbose) {
|
||||
std::cerr << "Error loading metadata from XMP sidecar: "
|
||||
<< exc.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,4 +297,16 @@ Exiv2::XmpData Exiv2Metadata::getXmpSidecar(const Glib::ustring &path)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void Exiv2Metadata::init()
|
||||
{
|
||||
Exiv2::XmpParser::initialize();
|
||||
}
|
||||
|
||||
|
||||
void Exiv2Metadata::cleanup()
|
||||
{
|
||||
Exiv2::XmpParser::terminate();
|
||||
}
|
||||
|
||||
} // namespace rtengine
|
||||
|
@@ -57,6 +57,9 @@ public:
|
||||
static Glib::ustring xmpSidecarPath(const Glib::ustring& path);
|
||||
static Exiv2::XmpData getXmpSidecar(const Glib::ustring& path);
|
||||
|
||||
static void init();
|
||||
static void cleanup();
|
||||
|
||||
private:
|
||||
void do_merge_xmp(Exiv2::Image* dst) const;
|
||||
void import_exif_pairs(Exiv2::ExifData& out) const;
|
||||
|
Reference in New Issue
Block a user