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 "autocroptask.h"
0016 
0017 // Qt includes
0018 
0019 #include <QFile>
0020 
0021 namespace DigikamGenericPanoramaPlugin
0022 {
0023 
0024 AutoCropTask::AutoCropTask(const QString& workDirPath,
0025                            const QUrl& autoOptimiserPtoUrl,
0026                            QUrl& viewCropPtoUrl,
0027                            bool /*buildGPano*/,
0028                            const QString& panoModifyPath)
0029     : CommandTask(PANO_AUTOCROP, workDirPath, panoModifyPath),
0030       autoOptimiserPtoUrl(autoOptimiserPtoUrl),
0031       viewCropPtoUrl(viewCropPtoUrl)
0032 /*    , buildGPano(buildGPano)
0033 */
0034 {
0035 }
0036 
0037 void AutoCropTask::run(ThreadWeaver::JobPointer, ThreadWeaver::Thread*)
0038 {
0039     viewCropPtoUrl = tmpDir;
0040     viewCropPtoUrl.setPath(viewCropPtoUrl.path() + QLatin1String("view_crop_pano.pto"));
0041 
0042     QStringList args;
0043     args << QLatin1String("-c");               // Center the panorama
0044     args << QLatin1String("-s");               // Straighten the panorama
0045     args << QLatin1String("--canvas=AUTO");    // Automatic size
0046     args << QLatin1String("--crop=AUTO");      // Automatic crop
0047     args << QLatin1String("-o");
0048     args << viewCropPtoUrl.toLocalFile();
0049     args << autoOptimiserPtoUrl.toLocalFile();
0050 
0051     runProcess(args);
0052 
0053     // PanoModify does not return an error code when something went wrong...
0054 
0055     QFile ptoOutput(viewCropPtoUrl.toLocalFile());
0056 
0057     if (!ptoOutput.exists())
0058     {
0059         successFlag = false;
0060         errString = getProcessError();
0061     }
0062 
0063     printDebug(QLatin1String("pano_modify"));
0064 }
0065 
0066 } // namespace DigikamGenericPanoramaPlugin