File indexing completed on 2025-01-05 03:56:02

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2008-09-25
0007  * Description : a tool to convert RAW file to DNG - Post process with ExifTool.
0008  *
0009  * SPDX-FileCopyrightText: 2008-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 #include "dngwriter_p.h"
0016 
0017 namespace Digikam
0018 {
0019 
0020 int DNGWriter::Private::exifToolPostProcess()
0021 {
0022     QScopedPointer<ExifToolParser> const parser(new ExifToolParser(nullptr));
0023 
0024     if (parser->exifToolAvailable())
0025     {
0026         qCDebug(DIGIKAM_GENERAL_LOG) << "DNGWriter: Post-process Iptc and Xmp with ExifTool";
0027 
0028         bool ret = parser->copyTags(
0029                                      inputInfo.filePath(),
0030                                      dngFilePath,
0031                                      ExifToolProcess::COPY_IPTC         |
0032                                      ExifToolProcess::COPY_XMP,
0033                                      ExifToolProcess::CREATE_NEW_TAGS   |
0034                                      ExifToolProcess::CREATE_NEW_GROUPS
0035                                    );
0036 
0037         if (!ret)
0038         {
0039             qCCritical(DIGIKAM_GENERAL_LOG) << "DNGWriter: Copy Iptc and Xmp tags with ExifTool failed. Aborted...";
0040 
0041             return PROCESS_FAILED;
0042         }
0043 
0044         // ---
0045 
0046         qCDebug(DIGIKAM_GENERAL_LOG) << "DNGWriter: Post-process markernotes with ExifTool";
0047 
0048         ret     = parser->copyTags(
0049                                      inputInfo.filePath(),
0050                                      dngFilePath,
0051                                      ExifToolProcess::COPY_MAKERNOTES
0052                                    );
0053 
0054         if (!ret)
0055         {
0056             qCCritical(DIGIKAM_GENERAL_LOG) << "DNGWriter: Copy markernotes with ExifTool failed. Aborted...";
0057 
0058             return PROCESS_FAILED;
0059         }
0060 
0061         // ---
0062 
0063         qCDebug(DIGIKAM_GENERAL_LOG) << "DNGWriter: Populate Xmp with ExifTool";
0064 
0065         ret      = parser->translateTags(
0066                                           dngFilePath,
0067                                           ExifToolProcess::TRANS_ALL_XMP
0068                                         );
0069 
0070         if (!ret)
0071         {
0072             qCCritical(DIGIKAM_GENERAL_LOG) << "DNGWriter: Populate Xmp tags with ExifTool failed. Aborted...";
0073 
0074             return PROCESS_FAILED;
0075         }
0076 
0077         // ---
0078 
0079         qCDebug(DIGIKAM_GENERAL_LOG) << "DNGWriter: Populate Iptc with ExifTool";
0080 
0081         ret      = parser->translateTags(
0082                                           dngFilePath,
0083                                           ExifToolProcess::TRANS_ALL_IPTC
0084                                         );
0085 
0086         if (!ret)
0087         {
0088             qCCritical(DIGIKAM_GENERAL_LOG) << "DNGWriter: Populate Iptc tags with ExifTool failed. Aborted...";
0089 
0090             return PROCESS_FAILED;
0091         }
0092     }
0093     else
0094     {
0095         qCWarning(DIGIKAM_GENERAL_LOG) << "DNGWriter: ExifTool is not available to post-process metadata...";
0096     }
0097 
0098     return PROCESS_CONTINUE;
0099 }
0100 
0101 } // namespace Digikam