Bug 127972 - digikam does not *add* EXIF:DateTimeOriginal when modifying date
Summary: digikam does not *add* EXIF:DateTimeOriginal when modifying date
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-Date (show other bugs)
Version: 0.9.0
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-24 21:36 UTC by Jens
Modified: 2017-08-12 06:42 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 0.9.0


Attachments
patch: change DateTimeOriginal, not -Digitized (1.52 KB, patch)
2006-05-30 00:03 UTC, Jens
Details
patch that changes DateTimeDigitized only when importing images (5.68 KB, patch)
2006-05-30 23:50 UTC, Jens
Details
patch that changes DateTimeDigitized only when importing images (6.28 KB, patch)
2006-05-30 23:53 UTC, Jens
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jens 2006-05-24 21:36:28 UTC
Version:           0.9.0-svn (using KDE 3.5.2 Level "a" , SUSE 10.0 UNSUPPORTED)
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.13-15.8-default

Hello,

when changing the picture date in the right-side "Comments & Tags" sidebar, Digikam is supposed to also change DateTimeOriginal (EXIF) and respective IPTC tags.

However, this only works if these tags existed previously. If they do not exist (e.g. my negative scanner only sets DateTimeDigitized, since it does not know about when the pic was taken), it is not added.

I would appreciate if this could be fixed. Also, I would like the value from the date to be automatically set in the file's mtime, or better yet, ctime (creation time) in the file system, if that's possible.

Thanks! :)

Jens
Comment 1 Jens 2006-05-24 21:58:18 UTC
Actually, it looks like Digikam wants to modifiy DateTimeDigitized in dmetadata.cpp:

bool DMetadata::setImageDateTime(const QDateTime& dateTime)
{
        // ....
        d->exifMetadata["Exif.Photo.DateTimeDigitized"] = exifdatetime;
        // ....

Isn't this incorrect? Shouldn't the date that is presented to the user be the date the photo was taken, in general?

(also in this file, further below, there is a setImageDimensions() function that outputs debug information about the file date/time, not the image dimensions. Might be misleading when searching for bugs later on ;) )

Thanks,

Jens
Comment 2 caulier.gilles 2006-05-24 22:09:35 UTC
Jens, this is not a bug (:=)))

I have volontary limited this implementation to fix DateTimeDigitized not DateTimeOriginal, to check/compare if really the date provided by camera is wrong. 

This is my idea :

DateTimeOriginal is the date from camera
DateTimeDigitized is the date fixed by digiKam

Note that both tags are set to the same value by camera normally.

The thread is open. If digiKam users want fix DateTimeOriginal at the same time by digiKam, there are just some line to add in DMetadata implementation

Gilles
Comment 3 Jens 2006-05-24 22:42:45 UTC
Ah, but DateTimeDigitized is set by scanners as the time an (analog) picture was imported / scanned / digitized. So this might overwrite the date the picture was scanned. My camera only sets DateTimeOriginal, my scanner software only sets DateTimeDigitized. (but then again my camera is from 2002 ...)

Jens
Comment 4 caulier.gilles 2006-05-24 23:11:37 UTC
Well Jens, you can make a little patch to fix it. It's a good exercice for you (:=)))

Gilles
Comment 5 Jens 2006-05-26 11:20:21 UTC
Thanks, I'm on it.

I also have the "small icons" (configurable) almost ready, I'll work on it over the weekend. I contacted Marcel about this too and he helped me get started. :-)

Jens
Comment 6 caulier.gilles 2006-05-26 12:32:03 UTC
Is your "small icons" patch provide a simple option into setup General page ?

Gilles
Comment 7 Jens 2006-05-26 12:52:22 UTC
No option yet, just a digikamrc value (IconSize).
I don't know how to do GUI elements yet. But I'll learn :-)
Comment 8 caulier.gilles 2006-05-26 14:23:16 UTC
ok. I recommend you to make 2 patch :

1- to use a value from digikamrc file to set album icon size.
2- to make a simple size settings into Setup genral tab. This one can be not simple to do for you if you unknow the ALbumSettings class. Make the gui is easy with Qt/KDE. Get inspiration from setupgeneral implementation.

Gilles
Comment 9 Jens 2006-05-29 00:07:43 UTC
Hi,
I added my new patch to bug 102029 (where it belongs). Please see my comment there, and review.
Jens
Comment 10 Jens 2006-05-30 00:03:02 UTC
Created attachment 16347 [details]
patch: change DateTimeOriginal, not -Digitized

Here is a patch so Digikam changes DateTimeOriginal.
Comment 11 caulier.gilles 2006-05-30 07:26:55 UTC
SVN commit 546459 by cgilles:

digikam from trunk : patch from Jens B.Benecke about to set Date & Time Original tags 
BUG: 127972

 M  +9 -3      dmetadata.cpp  


--- trunk/extragear/graphics/digikam/libs/dmetadata/dmetadata.cpp #546458:546459
@@ -738,19 +738,25 @@
 {
     try
     {    
-        kdDebug() << d->filePath << " ==> Date&Time: " << dateTime.toString(Qt::ISODate) << endl;
+        // In first we write date & time into Exif.
         
-        // In first we write date & time into Exif.
-                
+        // DateTimeDigitized is set by slide scanners etc. when a picture is digitized.
+        // DateTimeOriginal specifies the date/time when the picture was taken.
+        // For digital cameras, these dates should be both set, and identical.
+        // Reference: http://www.exif.org/Exif2-2.PDF, chapter 4.6.5, table 4, section F.
+
         const std::string &exifdatetime(dateTime.toString(Qt::ISODate).ascii());
         d->exifMetadata["Exif.Photo.DateTimeDigitized"] = exifdatetime;
+        d->exifMetadata["Exif.Photo.DateTimeOriginal"]  = exifdatetime;
         
         // In Second we write date & time into Iptc.
 
         const std::string &iptcdate(dateTime.date().toString(Qt::ISODate).ascii());
         d->iptcMetadata["Iptc.Application2.DigitizationDate"] = iptcdate;
+        d->iptcMetadata["Iptc.Application2.DateCreated"]      = iptcdate;
         const std::string &iptctime(dateTime.time().toString(Qt::ISODate).ascii());
         d->iptcMetadata["Iptc.Application2.DigitizationTime"] = iptctime;
+        d->iptcMetadata["Iptc.Application2.TimeCreated"]      = iptctime;
         
         setImageProgramId();
         return true;
Comment 12 Jens 2006-05-30 10:17:27 UTC
Hi Gilles,

are you mad when I still complain? :-)
IMHO, DateTimeDigitized should not be changed by Digikam, according to the EXIF spec. For digital cameras it does not matter, but for analog pictures that were scanned it does, since these specify two different values.

I propose the following:
If DateTimeOriginal and DateTimeDigitized are identical before Digikam changes them, update both. If they differ, only set DatetimeOriginal. This should be compatible with your idea in comment #2, but still retain the information when the pictures were scanned (as in my case).

If you are OK with this, I will prepare another patch. Then, I will look at some other bug reports of Digikam to help you out. :-)

Thanks :-)

Jens
Comment 13 caulier.gilles 2006-05-30 10:43:34 UTC
You have right. I need a coffee (:=)))...

This is my proposal : make a boolean operator in this method to set both or just one DateTime tags. Only the context will chose what we need to fix in Exif metadata.

This is want mean that you need to search in digiKam where this method is used. A grep is enough to find it. Normally is set during Camera download and when you use "Comment&Tags" sidebar tab.

- During Camera download both value need to be changed, because some cameras (like my Olympus C3000Z) set these values to 0!
- In Comment&Tags, only the DateTimeOriginal must be fixed.

Are you agree ? 

Gilles
Comment 14 Jens 2006-05-30 23:50:40 UTC
Created attachment 16365 [details]
patch that changes DateTimeDigitized only when importing images

Hi,

here is a patch that does that (I hope =) ).

Jens
Comment 15 Jens 2006-05-30 23:53:12 UTC
Created attachment 16367 [details]
patch that changes DateTimeDigitized only when importing images

I need to learn to patch properly. There was a change missing ... although not
fatal because I used a default parameter.

Here is the correct patch.

Jens
Comment 16 caulier.gilles 2006-05-31 00:25:44 UTC
SVN commit 546750 by cgilles:

digikam from trunk: patch from Jens B.Benecke about to fix Exif date and Time tags rules depending of context.
CCBUGS: 127972




 M  +9 -5      libs/dmetadata/dmetadata.cpp  
 M  +1 -1      libs/dmetadata/dmetadata.h  
 M  +1 -1      libs/imageproperties/imagedescedittab.cpp  
 M  +1 -1      utilities/cameragui/cameracontroller.cpp  
 M  +6 -5      utilities/cameragui/cameraui.cpp  


--- trunk/extragear/graphics/digikam/libs/dmetadata/dmetadata.cpp #546749:546750
@@ -734,7 +734,7 @@
     return QDateTime();
 }
 
-bool DMetadata::setImageDateTime(const QDateTime& dateTime)
+bool DMetadata::setImageDateTime(const QDateTime& dateTime, bool setDateTimeDigitized)
 {
     try
     {    
@@ -746,17 +746,21 @@
         // Reference: http://www.exif.org/Exif2-2.PDF, chapter 4.6.5, table 4, section F.
 
         const std::string &exifdatetime(dateTime.toString(Qt::ISODate).ascii());
-        d->exifMetadata["Exif.Photo.DateTimeDigitized"] = exifdatetime;
         d->exifMetadata["Exif.Photo.DateTimeOriginal"]  = exifdatetime;
+        if(setDateTimeDigitized)
+            d->exifMetadata["Exif.Photo.DateTimeDigitized"] = exifdatetime;
         
         // In Second we write date & time into Iptc.
 
         const std::string &iptcdate(dateTime.date().toString(Qt::ISODate).ascii());
-        d->iptcMetadata["Iptc.Application2.DigitizationDate"] = iptcdate;
-        d->iptcMetadata["Iptc.Application2.DateCreated"]      = iptcdate;
         const std::string &iptctime(dateTime.time().toString(Qt::ISODate).ascii());
-        d->iptcMetadata["Iptc.Application2.DigitizationTime"] = iptctime;
+        d->iptcMetadata["Iptc.Application2.DateCreated"] = iptcdate;
         d->iptcMetadata["Iptc.Application2.TimeCreated"]      = iptctime;
+        if(setDateTimeDigitized)
+        {
+            d->iptcMetadata["Iptc.Application2.DigitizationDate"] = iptcdate;
+            d->iptcMetadata["Iptc.Application2.DigitizationTime"] = iptctime;
+        }
         
         setImageProgramId();
         return true;
--- trunk/extragear/graphics/digikam/libs/dmetadata/dmetadata.h #546749:546750
@@ -101,7 +101,7 @@
     bool setExifThumbnail(const QImage& thumb);
     bool setImageDimensions(const QSize& size);
     bool setImageOrientation(ImageOrientation orientation);
-    bool setImageDateTime(const QDateTime& dateTime);
+    bool setImageDateTime(const QDateTime& dateTime, bool setDateTimeDigitized = false);
     bool setImageComment(const QString& comment);
     bool setImageRating(int rating);
     bool setImageKeywords(const QStringList& oldKeywords, const QStringList& newKeywords);
--- trunk/extragear/graphics/digikam/libs/imageproperties/imagedescedittab.cpp #546749:546750
@@ -410,7 +410,7 @@
         if (AlbumSettings::instance()->getSaveDateTime())
         {
             // Store Image Date & Time as Exif and Iptc tags.
-            metadata.setImageDateTime(d->dateTimeEdit->dateTime());
+            metadata.setImageDateTime(d->dateTimeEdit->dateTime(), false);
         }
 
         if (AlbumSettings::instance()->getSaveIptcRating())
--- trunk/extragear/graphics/digikam/utilities/cameragui/cameracontroller.cpp #546749:546750
@@ -354,7 +354,7 @@
                         DMetadata metadata(tempURL.path());
                         
                         if (fixDateTime)
-                            metadata.setImageDateTime(newDateTime);
+                            metadata.setImageDateTime(newDateTime, true);
                         
                         if (setPhotographerId)
                             metadata.setImagePhotographerId(author, authorTitle);
--- trunk/extragear/graphics/digikam/utilities/cameragui/cameraui.cpp #546749:546750
@@ -202,11 +202,11 @@
     d->autoRotateCheck  = new QCheckBox(i18n("Rotate/flip image"), exifBox);
     d->autoAlbumCheck   = new QCheckBox(i18n("Date-based sub-albums"), exifBox);
     QWhatsThis::add( d->autoRotateCheck, i18n("<p>Toogle on this option if you want automatically "
-                                              "rotated or fliped images using EXIF informations "
-                                              "provided by camera"));
+                                              "rotated or flipped images using EXIF information "
+                                              "provided by camera."));
     QWhatsThis::add( d->autoAlbumCheck, i18n("<p>Toogle on this option if you want downloaded photos "
                                              "into automatically created date-based sub-albums "
-                                             "of destination album"));
+                                             "of destination album."));
 
     QVGroupBox* OnFlyBox = new QVGroupBox(i18n("On the Fly Operations"), d->advBox);
     d->setPhotographerId = new QCheckBox(i18n("Set default photographer identity"), OnFlyBox);
@@ -216,11 +216,12 @@
     
     QWhatsThis::add( d->setPhotographerId, i18n("<p>Toogle on this option to store default photographer identity "
                                                 "into IPTC tags using main digiKam metadata settings."));
-    QWhatsThis::add( d->setCredits, i18n("<p>Toogle on this option to store default credit and copyrigth informations "
+    QWhatsThis::add( d->setCredits, i18n("<p>Toogle on this option to store default credit and copyright information "
                                          "into IPTC tags using main digiKam metadata settings."));
     QWhatsThis::add( d->fixDateTimeCheck, i18n("<p>Toogle on this option to set date and time metadata "
                                                "tags to the right values if your camera don't set "
-                                               "properlly these tags when pictures are taken."));
+                                               "properly these tags when pictures are taken. The values will"
+                                               "be saved in the DateTimeDigitized and DateTimeCreated EXIF/IPTC fields."));
                                                
     grid->addMultiCellWidget(d->renameCustomizer, 0, 0, 0, 1);
     grid->addMultiCellWidget(exifBox, 1, 1, 0, 1);