From a489e1cea7231a7fa9d97f2bb32da169273c5270 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sat, 9 Jan 2016 10:54:49 +0000 Subject: [PATCH] #1148 Fixed Todo: Should use XMP packet if there are no XMP modification commands --- src/actions.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index d6a29fa8..1ca9447f 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -1963,8 +1963,18 @@ namespace { std::cout << _("Writing XMP data from") << " " << source << " " << _("to") << " " << target << std::endl; } - // Todo: Should use XMP packet if there are no XMP modification commands - targetImage->setXmpData(sourceImage->xmpData()); + // #1148 use XMP packet if there are no XMP modification commands + if ( Params::instance().modifyCmds_.size() == 0 ) { + // http://www.cplusplus.com/reference/ostream/ostream/ostream/ + std::filebuf fb; + fb.open (target,std::ios::out); + std::ostream os(&fb); + sourceImage->printStructure(os,Exiv2::kpsXMP); + fb.close(); + return 0; + } else { + targetImage->setXmpData(sourceImage->xmpData()); + } } if ( Params::instance().target_ & Params::ctComment && !sourceImage->comment().empty()) {