Bug 108537 - WISH lossless jpeg rotations change file date/time. Could this be made optional since I want to keep the original file date/time
Summary: WISH lossless jpeg rotations change file date/time. Could this be made option...
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Bqm-Rotate (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-04 14:51 UTC by Stefan Zink
Modified: 2018-03-23 21:05 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 0.1.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Zink 2005-07-04 14:51:35 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    SuSE RPMs
OS:                Linux

lossless jpeg rotations change file date/time. 
Could this be made optional since I want to keep the original file date/time which is the date/time the photo was taken with my camera. I used Gwenview to do the rotations.
The file is immediately stored, but there is no option to leave the timestamp untouched.
Irfanview for example does this by default.
Comment 1 C.Anne Wilson 2005-07-04 18:25:48 UTC
Where nothing is done to the image other than rotation it would definitely be preferable to keep the original date.  I'll vote for it.
Comment 2 Renchi Raju 2005-07-11 07:22:20 UTC
SVN commit 433539 by pahlibar:

preserve timestamp of image when rotating/flipping
BUG: 108537


 M  +25 -3     utils.cpp  


--- trunk/extragear/libs/kipi-plugins/jpeglossless/utils.cpp #433538:433539
@@ -28,6 +28,9 @@
 extern "C" {
 #include <tiffio.h>
 #include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <utime.h>
 }
 
 #include "utils.h"
@@ -125,11 +128,30 @@
 
 bool MoveFile(const QString& src, const QString& dst)
 {
-    if (!CopyFile(src,dst)) return false;
+    struct stat stbuf;
+    if (::stat(QFile::encodeName(dst), &stbuf) != 0)
+    {
+        kdWarning( 51000 ) << "KIPIJPEGLossLessPlugin:MoveFile: failed to stat src"
+                           << endl;
+        return false;
+    }
+    
+    if (!CopyFile(src,dst))
+        return false;
 
-    if (::unlink(QFile::encodeName(src).data()) != 0) {
+    struct utimbuf timbuf;
+    timbuf.actime = stbuf.st_atime;
+    timbuf.modtime = stbuf.st_mtime;
+    if (::utime(QFile::encodeName(dst), &timbuf) != 0)
+    {
+        kdWarning( 51000 ) << "KIPIJPEGLossLessPlugin:MoveFile: failed to update dst time"
+                           << endl;
+    }
+    
+    if (::unlink(QFile::encodeName(src).data()) != 0)
+    {
         kdWarning( 51000 ) << "KIPIJPEGLossLessPlugin:MoveFile: failed to unlink src"
-                    << endl;
+                           << endl;
     }
     return true;
 }