Bug 307053

Summary: Images sorted incorrectly
Product: [Applications] digikam Reporter: DrSlony <bugs>
Component: Import-SortAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: major CC: bugs, caulier.gilles, wazery
Priority: NOR    
Version: 2.9.0   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In: 3.0.0
Sentry Crash Report:

Description DrSlony 2012-09-19 15:06:29 UTC
My photos are sorted incorrectly in the import panel (Import > USB Storage Device > USB Disk "Digital Camera" at /media/disk). As a result of this, they get renamed out of order, and this causes a headache, especially when shooting HDR panoramas.

The photos in this screenshot, IMGP3285-9, were bracketed in 5 steps with 1EV spacing between them (-2, -1, 0, 1, 2): http://i.imgur.com/XRl5A.jpg

Let's examine:

/media/disk/DCIM/105_0919 $ ls --full-time
(...)
-rw-r--r-- 1 drslony drslony  8477902 2012-09-19 12:26:40.000000000 +0100 IMGP3285.PEF
-rw-r--r-- 1 drslony drslony  9051467 2012-09-19 12:26:40.000000000 +0100 IMGP3286.PEF
-rw-r--r-- 1 drslony drslony  9878117 2012-09-19 12:26:42.000000000 +0100 IMGP3287.PEF
(...)

exiftool -L IMGP3285.PEF | egrep -i "(date|time)" 
File Modification Date/Time     : 2012:09:19 12:26:40+01:00
Modify Date                     : 2012:09:19 12:26:37
Date/Time Original              : 2012:09:19 12:26:37
Create Date                     : 2012:09:19 12:26:37

exiftool -L IMGP3286.PEF | egrep -i "(date|time)" 
File Modification Date/Time     : 2012:09:19 12:26:40+01:00
Modify Date                     : 2012:09:19 12:26:37
Date/Time Original              : 2012:09:19 12:26:37
Create Date                     : 2012:09:19 12:26:37

exiftool -L IMGP3287.PEF | egrep -i "(date|time)" 
File Modification Date/Time     : 2012:09:19 12:26:42+01:00
Modify Date                     : 2012:09:19 12:26:38
Date/Time Original              : 2012:09:19 12:26:38
Create Date                     : 2012:09:19 12:26:38

digiKam's import window shows the same values in the "Photograph Properties" panel and in the "EXIF" (sic, should be "Exif") and "Makernote" panels.
Additionally, it also shows the following times in the "Camera File Properties" panel:
IMGP3285.PEF - Date: 2012-09-19 12:26:38
IMGP3286.PEF - Date: 2012-09-19 12:26:40
IMGP3287.PEF - Date: 2012-09-19 12:26:40
I don't know where/how it got these times, "ls" and exiftool/exiv2 didn't show them, but I don't think they're a problem.

Reproducible: Always

Steps to Reproduce:
Shoot a series of bracketed photos with a very short exposure time so that your camera writes them all to the card in one go. Launch the import window in digiKam.
Actual Results:  
Some photos will have identical times because exposure time was so short they were recorded in the same second. My camera didn't mix them up while writing them - the filenames reflect this, they are in order. For some reason, the digiKam import window screws the order up, and so if I rename them on import I end up with photos in the wrong order.

Expected Results:  
I expect the import window to list the files in filename order if the timestamps are identical.

"Major: A major feature is broken"
I cannot use the import window at all until this is fixed, so it's a major issue. For now I have to manually copy the photos and run krename.
Comment 1 caulier.gilles 2012-09-19 16:10:18 UTC
By default, this time come from FS, not metadata. Why ? To collect quickly items information from camera device.

I already solved this issue, through bug #246401

Solution : force digiKam to collect items info from image metadata. warning : this can take a while. Go to Camera setup, and turn on right option (disabled by default)

Gilles Caulier
Comment 2 DrSlony 2012-09-19 19:58:38 UTC
Caulier thank you for looking into this, but unfortunately metadata time won't help, because it's identical for shots that were shot quickly in series. That's why I provided those exiftool/exiv2 results, unless you get the time from some other place? The only way to keep the correct order that I know of is to have that photo import window sort by filename, not by FS time or metadata time.
Comment 3 caulier.gilles 2012-09-19 20:41:53 UTC
No. there is no better way to extract date and time from metadata. After all it's stamp from camera device...

By default, Date and Time granularity is limited to 1 second in Exif.

There is perhaps a solution, if Markernotes as a better time resolution information to use. But, of course, it's not standardized...

The Filename items filter mst be implemented in 3.0.0 beta1. Islam ?

Gilles Caulier
Comment 4 Marcel Wiesweg 2012-09-20 19:07:51 UTC
If the (new, 3.0) model/view implementation is similar to the main view, the filename will be used as second criterion if the primary one, the time, is identical. It should, at least.
DrSlony: In the digikam main view, are the photos sorted correctly?
Comment 5 DrSlony 2012-10-16 18:44:18 UTC
@Marcel comment 4
The photos are not ordered correctly in the import from camera window.
If I import the photos without renaming them and sort them by filename then they show up correctly in the digiKam main view.
I have not tried to import the photos without renaming them and sort them by date in the digiKam main view.
If I import the photos and rename them #### on the fly and sort by file name then they will also show incorrectly in the digiKam main view.
Comment 6 Marcel Wiesweg 2012-10-17 16:06:20 UTC
Perhaps you can give us two photos which sort "B A" but should sort "A B" for testing.
Comment 7 DrSlony 2012-10-17 18:49:15 UTC
ad. comment 5:
If I import the photos without renaming them and sort them by date then they show up correctly in the digiKam main view.
If I import the photos and rename them #### on the fly and sort by file name then they will show incorrectly in the digiKam main view.
If I import the photos and rename them #### on the fly and sort by date then they will show incorrectly in the digiKam main view.

So this is a more human explanation of what's happening:
1- Some photos have an identical date when shot quickly in succession.
2- They are stored in the correct order on the memory card because the number in their filename is incremented in the correct order.
3- digiKam's Import window lists them in the incorrect order, which means it does not sort them by filename.
4- When imported without renaming, and the album is sorted by name or date, they are shown in the correct order. This means that when they are sorted by date and the date of two or more photos is identical, then digiKam falls back on the filename (which is good).
5- When imported with renaming to ###, they are numbered in the same incorrect order that they appear in in the Import window. When I sort by date, the order does not change. This is weird. Why would sorting by date show them in the correct order in point 4, but not here?

Here are 6 sample photos for your enjoyment [54MB]:
http://filebin.net/zkfwzmu5cb/file/bug_307053_photo_sort_order.tar.bz
Comment 8 Marcel Wiesweg 2013-01-12 21:22:43 UTC
In the 3.0 import window, your six sample images in a short test are sorted as the file name sequence number suggests, regardless if I sort by date or by filename.
Your comment 7 refers to 3.0 as well?
Comment 9 DrSlony 2013-01-12 22:20:02 UTC
Marcel: no, it referred to 2.9.0.
Thank you for the fix :)
Comment 10 Christoph Feck 2013-01-19 18:27:51 UTC
If this is fixed in 3.0.0, please close it.