Commit 5507cb4c authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

ExifToolParser: new command to copy tags from source file to a destination file.

CCBUGS: 134486, 170693, 219856, 237504, 264210, 309341, 325458, 326408, 377622, 384092, 406540, 416516, 421464, 436286, 381967
parent 80802f22
Pipeline #62099 passed with stage
in 35 minutes and 14 seconds
......@@ -157,6 +157,13 @@ public:
*/
bool translationsList();
/**
* Copy group of tags from one source file to a destination file, following copy operations defined by 'copyOps'.
* 'copyOps' is a OR combination of ExifToolProcess::CopyTagsSource values.
* 'dst' must be a writable file format supported by ExifTool.
*/
bool copyTags(const QString& src, const QString& dst, int copyOps);
//@}
private Q_SLOTS:
......
......@@ -233,4 +233,68 @@ bool ExifToolParser::translationsList()
return (d->startProcess(cmdArgs, ExifToolProcess::TRANSLATIONS_LIST));
}
bool ExifToolParser::copyTags(const QString& src, const QString& dst, int copyOps)
{
QFileInfo sfi(src);
if (!sfi.exists())
{
return false;
}
QFileInfo dfi(src);
if (!dfi.exists())
{
return false;
}
QByteArrayList copyCmds;
if (copyOps & ExifToolProcess::COPY_EXIF)
{
copyCmds << QByteArray("-exif");
}
if (copyOps & ExifToolProcess::COPY_MAKERNOTES)
{
copyCmds << QByteArray("-makernotes");
}
if (copyOps & ExifToolProcess::COPY_IPTC)
{
copyCmds << QByteArray("-iptc");
}
if (copyOps & ExifToolProcess::COPY_XMP)
{
copyCmds << QByteArray("-xmp");
}
if (copyOps & ExifToolProcess::COPY_ALL)
{
copyCmds << QByteArray("-all:all");
}
if (copyCmds.isEmpty())
{
return false;
}
if (!d->prepareProcess())
{
return false;
}
QByteArrayList cmdArgs;
cmdArgs << QByteArray("-TagsFromFile");
cmdArgs << d->filePathEncoding(src);
cmdArgs << copyCmds;
cmdArgs << d->filePathEncoding(dst);
d->currentPath = sfi.path();
return (d->startProcess(cmdArgs, ExifToolProcess::COPY_TAGS));
}
} // namespace Digikam
......@@ -47,6 +47,9 @@ class DIGIKAM_EXPORT ExifToolProcess : public QObject
public:
/**
* ExifTool actions to process.
*/
enum Action
{
LOAD_METADATA = 0, ///< Load all metadata from a file with ExifTool.
......@@ -55,10 +58,23 @@ public:
APPLY_CHANGES_EXV, ///< Apply tag changes in a file with ExifTool using an EXV container.
READ_FORMATS, ///< Return the list of readable ExifTool file formats.
WRITE_FORMATS, ///< Return the list of writable ExifTool file formats.
TRANSLATIONS_LIST, ///< List of ExifTool languages avaialble for translations.
TRANSLATIONS_LIST, ///< List of ExifTool languages available for translations.
COPY_TAGS, ///< Copy tags from one file to another one. See CopyTagsSource enum for details.
NO_ACTION ///< Last value from this list.
};
/**
* Possible operations to combine with COPY_TAGS action.
*/
enum CopyTagsSource
{
COPY_EXIF = 0x01, ///< Copy all Exif Tags from source file.
COPY_MAKERNOTES = 0x02, ///< Copy all Makernotes tags from source file.
COPY_IPTC = 0x04, ///< Copy all Iptc tags from source file.
COPY_XMP = 0x08, ///< Copy all Xmp tags from source file.
COPY_ALL = 0x0A ///< Copy all tags from source file.
};
public:
/**
......
Markdown is supported
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