File indexing completed on 2025-01-05 03:53:10

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2012-03-15
0007  * Description : a tool to create panorama by fusion of several images.
0008  *
0009  * SPDX-FileCopyrightText: 2012-2016 by Benjamin Girault <benjamin dot girault at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "createmktask.h"
0016 
0017 // Qt includes
0018 
0019 #include <QFileInfo>
0020 
0021 // Local includes
0022 
0023 #include "digikam_debug.h"
0024 #include "digikam_globals.h"
0025 
0026 namespace DigikamGenericPanoramaPlugin
0027 {
0028 
0029 CreateMKTask::CreateMKTask(const QString& workDirPath, const QUrl& input, QUrl& mkUrl,
0030                            QUrl& panoUrl, PanoramaFileType fileType,
0031                            const QString& pto2mkPath, bool preview)
0032     : CommandTask(preview ? PANO_CREATEMKPREVIEW : PANO_CREATEMK, workDirPath, pto2mkPath),
0033       ptoUrl(input),
0034       mkUrl(mkUrl),
0035       panoUrl(panoUrl),
0036       fileType(fileType)
0037 {
0038 }
0039 
0040 CreateMKTask::~CreateMKTask()
0041 {
0042 }
0043 
0044 void CreateMKTask::run(ThreadWeaver::JobPointer, ThreadWeaver::Thread*)
0045 {
0046     panoUrl = tmpDir;
0047     mkUrl   = tmpDir;
0048     QFileInfo fi(ptoUrl.toLocalFile());
0049     mkUrl.setPath(mkUrl.path() + fi.completeBaseName() + QLatin1String(".mk"));
0050 
0051     switch (fileType)
0052     {
0053         case JPEG:
0054             panoUrl.setPath(panoUrl.path() + fi.completeBaseName() + QLatin1String(".jpg"));
0055             break;
0056 
0057         case TIFF:
0058             panoUrl.setPath(panoUrl.path() + fi.completeBaseName() + QLatin1String(".tif"));
0059             break;
0060 
0061         case HDR:
0062             panoUrl.setPath(panoUrl.path() + fi.completeBaseName() + QLatin1String(".hdr"));
0063             break;
0064     }
0065 
0066     QStringList args;
0067     args << QLatin1String("-o");
0068     args << mkUrl.toLocalFile();
0069     args << QLatin1String("-p");
0070     args << fi.completeBaseName();
0071     args << ptoUrl.toLocalFile();
0072 
0073     runProcess(args);
0074 
0075     qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "pto2mk command line: " << getCommandLine();
0076 
0077     qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << "pto2mk output:" << QT_ENDL << output;
0078 }
0079 
0080 } // namespace DigikamGenericPanoramaPlugin