Commit 80ecdd99 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

Use only ExifTool backend to write metadata to RAW files, as Exiv2 is fully...

Use only ExifTool backend to write metadata to RAW files, as Exiv2 is fully unsafe with these kind of operations.
Reading and Writing metadata to video files is now delegate to ExifTool Backend too.
BUGS: 406540
BUGS: 416516
BUGS: 237504
BUGS: 384092
BUGS: 264210
BUGS: 326408
BUGS: 134486
BUGS: 309341
BUGS: 377622
BUGS: 170693
BUGS: 419801
BUGS: 338075
BUGS: 366348
FIXED-IN: 8.0.0
parent e43658c6
Pipeline #161081 failed with stage
in 18 minutes and 36 seconds
......@@ -8,6 +8,7 @@ General : Add JPEG-XL, WEBP, and AVIF export settings everywhere.
Add convert to lossless JPEG-XL, WEBP, and AVIF while importing from camera.
Add JPEG-XL; WEBP, and AVIF converters in Batch Queue Manager.
Usability: Add hamburger menu to tool-bar if main menu is hidden.
Metadata: Write to RAW and Video files is now delegate to ExifTool Backend.
*****************************************************************************************************
BUGFIXES:
......
......@@ -29,11 +29,13 @@
#include <QString>
#include <QScopedPointer>
#include <QFileInfo>
// Local includes
#include "digikam_config.h"
#include "digikam_debug.h"
#include "drawfiles.h"
#include "exiftoolparser.h"
namespace Digikam
......@@ -93,6 +95,17 @@ bool DMetadata::loadUsingExifTool(const QString& filePath)
bool DMetadata::saveUsingExifTool(const QString& filePath) const
{
QFileInfo finfo(filePath);
QString ext = finfo.suffix().toLower();
if (!writeRawFiles() && s_rawFileExtensions().contains(ext))
{
qCDebug(DIGIKAM_METAENGINE_LOG) << finfo.fileName()
<< "is a RAW file, "
<< "writing to such a file is disabled by current settings.";
return false;
}
ExifToolParser* const parser = new ExifToolParser(nullptr);
if (parser->exifToolAvailable())
......
......@@ -51,6 +51,7 @@ extern "C"
#include "digikam_debug.h"
#include "digikam_config.h"
#include "metaengine_data_p.h"
#include "drawfiles.h"
// Pragma directives to reduce warnings from Exiv2.
......@@ -221,70 +222,23 @@ bool MetaEngine::Private::saveToFile(const QFileInfo& finfo) const
return false;
}
QStringList rawTiffBasedSupported, rawTiffBasedNotSupported;
// Raw files supported by Exiv2 0.27
rawTiffBasedSupported << QLatin1String("cr2")
<< QLatin1String("crw")
<< QLatin1String("nef")
<< QLatin1String("pef")
<< QLatin1String("orf")
<< QLatin1String("srw");
// Raw files not supported by Exiv2 0.27
rawTiffBasedNotSupported << QLatin1String("3fr")
<< QLatin1String("arw")
<< QLatin1String("dcr")
<< QLatin1String("erf")
<< QLatin1String("k25")
<< QLatin1String("kdc")
<< QLatin1String("mos")
<< QLatin1String("mrw")
<< QLatin1String("raf")
<< QLatin1String("raw")
<< QLatin1String("rw2")
<< QLatin1String("sr2")
<< QLatin1String("srf")
<< QLatin1String("rw2");
if (!writeDngFiles)
{
rawTiffBasedNotSupported << (QLatin1String("dng"));
}
QString ext = finfo.suffix().toLower();
if (rawTiffBasedNotSupported.contains(ext) || (!writeRawFiles && rawTiffBasedSupported.contains(ext)))
if (s_rawFileExtensions().remove(QLatin1String("dng")).contains(ext))
{
qCDebug(DIGIKAM_METAENGINE_LOG) << finfo.fileName()
<< "is a TIFF based RAW file, "
<< "writing to such a file is disabled by current settings.";
return false;
}
// NOTE: never touch RAW files with Exiv2 as it's not safe. Delegate to ExifTool backens.
/*
if (rawTiffBasedNotSupported.contains(ext))
{
qCDebug(DIGIKAM_METAENGINE_LOG) << finfo.fileName()
<< "is TIFF based RAW file not yet supported. Metadata not saved.";
return false;
}
if (rawTiffBasedSupported.contains(ext) && !writeRawFiles)
if (!writeDngFiles && (ext == QLatin1String("dng")))
{
qCDebug(DIGIKAM_METAENGINE_LOG) << finfo.fileName()
<< "is TIFF based RAW file supported but writing mode is disabled. "
<< "Metadata not saved.";
<< "is a DNG file, "
<< "writing to such a file is disabled by current settings.";
return false;
}
qCDebug(DIGIKAM_METAENGINE_LOG) << "File Extension: " << ext << " is supported for writing mode";
bool ret = false;
*/
QMutexLocker lock(&s_metaEngineMutex);
try
......
......@@ -254,34 +254,18 @@ void SetupMetadata::slotWriteRawFilesToggled(bool b)
QPointer<QMessageBox> msgBox1 = new QMessageBox(QMessageBox::Warning,
qApp->applicationName(),
i18nc("@info",
"Do you really want to enable metadata writing to RAW files? "
"digiKam delegates this task to the Exiv2 library.\n"
"With different RAW formats, problems are known which can "
"lead to the destruction of RAW files.\n"
"If you decide to do so, make a backup of your RAW files. "
"We strongly recommend not to enable this option."),
"Do you really want to enable metadata writing to RAW files?\n"
"Note: digiKam delegates this task to the ExifTool backend."),
QMessageBox::Yes | QMessageBox::No, this);
msgBox1->button(QMessageBox::Yes)->setText(i18nc("@action", "Yes I understand"));
msgBox1->setDefaultButton(QMessageBox::No);
int result1 = msgBox1->exec();
delete msgBox1;
if (result1 == QMessageBox::Yes)
if (result1 == QMessageBox::No)
{
QPointer<QMessageBox> msgBox2 = new QMessageBox(QMessageBox::Warning,
qApp->applicationName(),
i18nc("@info", "You would rather disable writing metadata to RAW files?"),
QMessageBox::Yes | QMessageBox::No, this);
int result2 = msgBox2->exec();
delete msgBox2;
if (result2 == QMessageBox::No)
{
return;
}
return;
}
d->writeRawFilesBox->setChecked(false);
......
......@@ -132,10 +132,9 @@ void SetupMetadata::appendBehaviorTab()
d->writeDngFilesBox->setEnabled(MetaEngine::supportMetadataWriting(QLatin1String("image/x-raw")));
d->writeRawFilesBox = new QCheckBox;
d->writeRawFilesBox->setText(i18nc("@option:check", "If possible write metadata to RAW files (Dangerous)"));
d->writeRawFilesBox->setWhatsThis(i18nc("@info:whatsthis", "Turn on this option to write metadata into RAW TIFF/EP files. "
"This feature requires the Exiv2 shared library, version >= 0.18.0. It is still "
"experimental, and is disabled by default. Activate this option only if you know what you are doing."));
d->writeRawFilesBox->setText(i18nc("@option:check", "If possible write metadata to RAW files"));
d->writeRawFilesBox->setWhatsThis(i18nc("@info:whatsthis", "Turn on this option to write metadata into RAW files. "
"This feature is delegate to ExifTool backend and is disabled by default."));
d->writeRawFilesBox->setEnabled(MetaEngine::supportMetadataWriting(QLatin1String("image/x-raw")));
d->updateFileTimeStampBox = new QCheckBox;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment