File indexing completed on 2025-01-05 03:58:13
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2013-11-28 0007 * Description : a command line tool to write metadata with ExifTool 0008 * 0009 * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 // Qt includes 0016 0017 #include <QString> 0018 #include <QCoreApplication> 0019 #include <QVariant> 0020 0021 // Local includes 0022 0023 #include "dimg.h" 0024 #include "digikam_debug.h" 0025 #include "dpluginloader.h" 0026 #include "metaengine.h" 0027 #include "exiftoolparser.h" 0028 0029 using namespace Digikam; 0030 0031 int main(int argc, char** argv) 0032 { 0033 QCoreApplication app(argc, argv); 0034 0035 if (argc != 2) 0036 { 0037 qCDebug(DIGIKAM_TESTS_LOG) << "exiftoolwrite_cli - CLI tool to write metadata with ExifTool in image"; 0038 qCDebug(DIGIKAM_TESTS_LOG) << "Usage: <image to patch>"; 0039 return -1; 0040 } 0041 0042 MetaEngine::initializeExiv2(); 0043 DPluginLoader::instance()->init(); 0044 0045 // Write all metadata to an empty JPG file. 0046 0047 DImg file(1, 1, false); 0048 file.save(QString::fromUtf8(argv[1]), DImg::JPEG); 0049 0050 // Create ExifTool parser instance. 0051 0052 ExifToolParser* const parser = new ExifToolParser(qApp); 0053 0054 ExifToolParser::ExifToolData newTags; 0055 newTags.insert(QLatin1String("EXIF:ImageDescription"), 0056 QVariantList() << QString() // not used 0057 << QString::fromUtf8("J'ai reçu cette photo par la poste en Février")); 0058 newTags.insert(QLatin1String("xmp:city"), 0059 QVariantList() << QString() // not used 0060 << QString::fromUtf8("Paris")); 0061 0062 // Read metadata from the file. Start ExifToolParser 0063 0064 if (!parser->applyChanges(QString::fromUtf8(argv[1]), newTags)) 0065 { 0066 return -1; 0067 } 0068 0069 return 0; 0070 }