[Kde-imaging] [kipiplugins] [Bug 256466] Shot info preservation from original files to target file

Gilles Caulier caulier.gilles at gmail.com
Sat Aug 2 05:11:58 UTC 2014


https://bugs.kde.org/show_bug.cgi?id=256466

--- Comment #15 from Gilles Caulier <caulier.gilles at gmail.com> ---
Git commit fe279dc1be18b57854fae4476f2a10e7c4cc9c7f by Gilles Caulier.
Committed on 02/08/2014 at 05:10.
Pushed by cgilles into branch 'master'.

Panorama Tool : Store common metadata info as ExpoBlending tool

M  +60   -29   panorama/tasks/copyfilestask.cpp

http://commits.kde.org/kipi-plugins/fe279dc1be18b57854fae4476f2a10e7c4cc9c7f

diff --git a/panorama/tasks/copyfilestask.cpp
b/panorama/tasks/copyfilestask.cpp
index 0e4f51c..66db952 100644
--- a/panorama/tasks/copyfilestask.cpp
+++ b/panorama/tasks/copyfilestask.cpp
@@ -44,49 +44,31 @@ CopyFilesTask::CopyFilesTask(QObject* parent, const KUrl&
workDir, const KUrl& p
                              const KUrl& ptoUrl, const ItemUrlsMap& urls, bool
savePTO, bool addGPlusMetadata)
     : Task(parent, COPY, workDir), panoUrl(panoUrl),
finalPanoUrl(finalPanoUrl),
       ptoUrl(ptoUrl), urlList(&urls), savePTO(savePTO),
addGPlusMetadata(addGPlusMetadata)
-{}
+{
+}

 CopyFilesTask::CopyFilesTask(const KUrl& workDir, const KUrl& panoUrl, const
KUrl& finalPanoUrl,
                              const KUrl& ptoUrl, const ItemUrlsMap& urls, bool
savePTO, bool addGPlusMetadata)
     : Task(0, COPY, workDir), panoUrl(panoUrl), finalPanoUrl(finalPanoUrl),
       ptoUrl(ptoUrl), urlList(&urls), savePTO(savePTO),
addGPlusMetadata(addGPlusMetadata)
-{}
+{
+}

 CopyFilesTask::~CopyFilesTask()
-{}
+{
+}

 void CopyFilesTask::run()
 {
-    QFile panoFile(panoUrl.toLocalFile());
-    QFile finalPanoFile(finalPanoUrl.toLocalFile());
+    QFile     panoFile(panoUrl.toLocalFile());
+    QFile     finalPanoFile(finalPanoUrl.toLocalFile());

     QFileInfo fi(finalPanoUrl.toLocalFile());
-    KUrl finalPTOUrl(finalPanoUrl);
+    KUrl      finalPTOUrl(finalPanoUrl);
     finalPTOUrl.setFileName(fi.completeBaseName() + ".pto");
-    QFile ptoFile(ptoUrl.toLocalFile());
-    QFile finalPTOFile(finalPTOUrl.toLocalFile());

-    kDebug() << "Copying GPS info...";
-
-    // Find first src image which contain geolocation and save it to target
pano file.
-
-    double lat, lng, alt;
-
-    for (ItemUrlsMap::const_iterator i = urlList->constBegin(); i !=
urlList->constEnd(); ++i)
-    {
-        kDebug() << i.key();
-
-        KPMetadata metaSrc(i.key().toLocalFile());
-
-        if(metaSrc.getGPSInfo(alt, lat, lng))
-        {
-            kDebug() << "GPS info found and saved in " << panoUrl;
-            KPMetadata metaDst(panoUrl.toLocalFile());
-            metaDst.setGPSInfo(alt, lat, lng);
-            metaDst.applyChanges();
-            break;
-        }
-    }
+    QFile     ptoFile(ptoUrl.toLocalFile());
+    QFile     finalPTOFile(finalPTOUrl.toLocalFile());

     if (!panoFile.exists())
     {
@@ -95,6 +77,7 @@ void CopyFilesTask::run()
         successFlag = false;
         return;
     }
+
     if (finalPanoFile.exists())
     {
         errString = i18n("A file named %1 already exists.",
finalPanoUrl.fileName());
@@ -102,6 +85,7 @@ void CopyFilesTask::run()
         successFlag = false;
         return;
     }
+
     if (savePTO && !ptoFile.exists())
     {
         errString = i18n("Temporary project file does not exist.");
@@ -109,6 +93,7 @@ void CopyFilesTask::run()
         successFlag = false;
         return;
     }
+
     if (savePTO && finalPTOFile.exists())
     {
         errString = i18n("A file named %1 already exists.",
finalPTOUrl.fileName());
@@ -116,8 +101,51 @@ void CopyFilesTask::run()
         successFlag = false;
         return;
     }
+
+    kDebug() << "Copying GPS info...";
+
+    // Find first src image which contain geolocation and save it to target
pano file.
+
+    double lat, lng, alt;
+
+    for (ItemUrlsMap::const_iterator i = urlList->constBegin(); i !=
urlList->constEnd(); ++i)
+    {
+        kDebug() << i.key();
+
+        KPMetadata metaSrc(i.key().toLocalFile());
+
+        if(metaSrc.getGPSInfo(alt, lat, lng))
+        {
+            kDebug() << "GPS info found and saved in " << panoUrl;
+            KPMetadata metaDst(panoUrl.toLocalFile());
+            metaDst.setGPSInfo(alt, lat, lng);
+            metaDst.applyChanges();
+            break;
+        }
+    }
+
+    // Restore usual and common metadata from first shot.
+
+    KPMetadata metaSrc(urlList->constBegin().key().toLocalFile());
+    KPMetadata metaDst(panoUrl.toLocalFile());
+    metaDst.setIptc(metaSrc.getIptc());
+    metaDst.setXmp(metaSrc.getXmp());
+    metaDst.setXmpTagString("Xmp.tiff.Make", 
metaSrc.getExifTagString("Exif.Image.Make"));
+    metaDst.setXmpTagString("Xmp.tiff.Model",
metaSrc.getExifTagString("Exif.Image.Model"));
+
+    QString filesList;
+
+    for (ItemUrlsMap::const_iterator i = urlList->constBegin(); i !=
urlList->constEnd(); ++i)
+        filesList.append(i.key().fileName() + " ; ");
+
+    filesList.truncate(filesList.length()-3);
+
+    metaDst.setXmpTagString("Xmp.kipi.PanoramaInputFiles", filesList, false);
+    metaDst.setImageDateTime(QDateTime::currentDateTime());
+    metaDst.applyChanges();

     kDebug() << "Copying panorama file...";
+
     if (!panoFile.copy(finalPanoUrl.toLocalFile()) || !panoFile.remove())
     {
         errString = i18n("Cannot move panorama from %1 to %2.",
@@ -143,6 +171,7 @@ void CopyFilesTask::run()
     if (savePTO)
     {
         kDebug() << "Copying project file...";
+
         if (!ptoFile.copy(finalPTOUrl.toLocalFile()))
         {
             errString = i18n("Cannot move project file from %1 to %2.",
@@ -153,6 +182,7 @@ void CopyFilesTask::run()
         }

         kDebug() << "Copying converted RAW files...";
+
         for (ItemUrlsMap::const_iterator i = urlList->constBegin(); i !=
urlList->constEnd(); ++i)
         {
             if (KPMetadata::isRawFile(i.key()))
@@ -160,6 +190,7 @@ void CopyFilesTask::run()
                 KUrl finalImgUrl(finalPanoUrl);
                 finalImgUrl.setFileName(i->preprocessedUrl.fileName());
                 QFile imgFile(i->preprocessedUrl.toLocalFile());
+
                 if (!imgFile.copy(finalImgUrl.toLocalFile()))
                 {
                     errString = i18n("Cannot copy converted image file from %1
to %2.",

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Kde-imaging mailing list