|
|
@ -113,12 +113,15 @@ namespace {
|
|
|
|
@param source Source file path
|
|
|
|
@param source Source file path
|
|
|
|
@param target Target file path. An *.exv file is created if target doesn't
|
|
|
|
@param target Target file path. An *.exv file is created if target doesn't
|
|
|
|
exist.
|
|
|
|
exist.
|
|
|
|
|
|
|
|
@param targetType Image type for the target image in case it needs to be
|
|
|
|
|
|
|
|
created.
|
|
|
|
@param preserve Indicates if existing metadata in the target file should
|
|
|
|
@param preserve Indicates if existing metadata in the target file should
|
|
|
|
be kept.
|
|
|
|
be kept.
|
|
|
|
@return 0 if successful, else an error code
|
|
|
|
@return 0 if successful, else an error code
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
int metacopy(const std::string& source,
|
|
|
|
int metacopy(const std::string& source,
|
|
|
|
const std::string& target,
|
|
|
|
const std::string& target,
|
|
|
|
|
|
|
|
int targetType,
|
|
|
|
bool preserve);
|
|
|
|
bool preserve);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
@ -1022,13 +1025,15 @@ namespace Action {
|
|
|
|
rc = writeThumbnail();
|
|
|
|
rc = writeThumbnail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Params::instance().target_ & Params::ctXmpSidecar) {
|
|
|
|
if (Params::instance().target_ & Params::ctXmpSidecar) {
|
|
|
|
rc = writeXmpSidecar();
|
|
|
|
std::string xmpPath = newFilePath(path_, ".xmp");
|
|
|
|
|
|
|
|
if (dontOverwrite(xmpPath)) return 0;
|
|
|
|
|
|
|
|
rc = metacopy(path_, xmpPath, Exiv2::ImageType::xmp, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !(Params::instance().target_ & Params::ctXmpSidecar)
|
|
|
|
if ( !(Params::instance().target_ & Params::ctXmpSidecar)
|
|
|
|
&& !(Params::instance().target_ & Params::ctThumb)) {
|
|
|
|
&& !(Params::instance().target_ & Params::ctThumb)) {
|
|
|
|
std::string exvPath = newFilePath(path_, ".exv");
|
|
|
|
std::string exvPath = newFilePath(path_, ".exv");
|
|
|
|
if (dontOverwrite(exvPath)) return 0;
|
|
|
|
if (dontOverwrite(exvPath)) return 0;
|
|
|
|
rc = metacopy(path_, exvPath, false);
|
|
|
|
rc = metacopy(path_, exvPath, Exiv2::ImageType::exv, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1039,43 +1044,6 @@ namespace Action {
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
} // Extract::run
|
|
|
|
} // Extract::run
|
|
|
|
|
|
|
|
|
|
|
|
int Extract::writeXmpSidecar() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Exiv2::fileExists(path_, true)) {
|
|
|
|
|
|
|
|
std::cerr << path_
|
|
|
|
|
|
|
|
<< ": " << _("Failed to open the file\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path_);
|
|
|
|
|
|
|
|
assert(image.get() != 0);
|
|
|
|
|
|
|
|
image->readMetadata();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string sidecarPath = newFilePath(path_, ".xmp");
|
|
|
|
|
|
|
|
if (dontOverwrite(sidecarPath)) return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Apply any modification commands to the source image on-the-fly
|
|
|
|
|
|
|
|
Action::Modify::applyCommands(image.get());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Exiv2::Image::AutoPtr xmpSidecar =
|
|
|
|
|
|
|
|
Exiv2::ImageFactory::create(Exiv2::ImageType::xmp, sidecarPath);
|
|
|
|
|
|
|
|
assert(xmpSidecar.get() != 0);
|
|
|
|
|
|
|
|
if (Params::instance().verbose_) {
|
|
|
|
|
|
|
|
std::cout << _("Writing XMP sidecar file ") << " "
|
|
|
|
|
|
|
|
<< sidecarPath << std::endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Params::instance().target_ & Params::ctExif) {
|
|
|
|
|
|
|
|
xmpSidecar->setExifData(image->exifData());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Params::instance().target_ & Params::ctIptc) {
|
|
|
|
|
|
|
|
xmpSidecar->setIptcData(image->iptcData());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Params::instance().target_ & Params::ctXmp) {
|
|
|
|
|
|
|
|
xmpSidecar->setXmpData(image->xmpData());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
xmpSidecar->writeMetadata();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
} // Extract::writeXmpSidecar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Extract::writeThumbnail() const
|
|
|
|
int Extract::writeThumbnail() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!Exiv2::fileExists(path_, true)) {
|
|
|
|
if (!Exiv2::fileExists(path_, true)) {
|
|
|
@ -1148,8 +1116,9 @@ namespace Action {
|
|
|
|
|| Params::instance().target_ & Params::ctXmp)) {
|
|
|
|
|| Params::instance().target_ & Params::ctXmp)) {
|
|
|
|
std::string suffix = Params::instance().suffix_;
|
|
|
|
std::string suffix = Params::instance().suffix_;
|
|
|
|
if (suffix.empty()) suffix = ".exv";
|
|
|
|
if (suffix.empty()) suffix = ".exv";
|
|
|
|
|
|
|
|
if (Params::instance().target_ & Params::ctXmpSidecar) suffix = ".xmp";
|
|
|
|
std::string exvPath = newFilePath(path, suffix);
|
|
|
|
std::string exvPath = newFilePath(path, suffix);
|
|
|
|
rc = metacopy(exvPath, path, true);
|
|
|
|
rc = metacopy(exvPath, path, Exiv2::ImageType::none, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (0 == rc && Params::instance().target_ & Params::ctXmpSidecar) {
|
|
|
|
if (0 == rc && Params::instance().target_ & Params::ctXmpSidecar) {
|
|
|
|
rc = insertXmpPacket(path);
|
|
|
|
rc = insertXmpPacket(path);
|
|
|
@ -1751,6 +1720,7 @@ namespace {
|
|
|
|
|
|
|
|
|
|
|
|
int metacopy(const std::string& source,
|
|
|
|
int metacopy(const std::string& source,
|
|
|
|
const std::string& target,
|
|
|
|
const std::string& target,
|
|
|
|
|
|
|
|
int targetType,
|
|
|
|
bool preserve)
|
|
|
|
bool preserve)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!Exiv2::fileExists(source, true)) {
|
|
|
|
if (!Exiv2::fileExists(source, true)) {
|
|
|
@ -1772,8 +1742,7 @@ namespace {
|
|
|
|
if (preserve) targetImage->readMetadata();
|
|
|
|
if (preserve) targetImage->readMetadata();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
targetImage
|
|
|
|
targetImage = Exiv2::ImageFactory::create(targetType, target);
|
|
|
|
= Exiv2::ImageFactory::create(Exiv2::ImageType::exv, target);
|
|
|
|
|
|
|
|
assert(targetImage.get() != 0);
|
|
|
|
assert(targetImage.get() != 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( Params::instance().target_ & Params::ctExif
|
|
|
|
if ( Params::instance().target_ & Params::ctExif
|
|
|
|