Bug 474366 - HEIC thumbnail rotation
Summary: HEIC thumbnail rotation
Status: RESOLVED WORKSFORME
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-DImg-HEIF (show other bugs)
Version: 8.1.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-10 13:30 UTC by Paul Worrall
Modified: 2023-10-24 14:29 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 8.2.0
Sentry Crash Report:


Attachments
File with thumbnail rotated 90 counter-clockwise (1.87 MB, image/heif)
2023-09-10 16:01 UTC, Paul Worrall
Details
My settings under Metadata -> Rotation (121.09 KB, image/png)
2023-09-10 22:28 UTC, Paul Worrall
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Worrall 2023-09-10 13:30:40 UTC
SUMMARY
Thumbnails of HEIC files from an iPhone are displayed in the wrong orientation, and the rotate button sometimes rotates by more than 90 deg

STEPS TO REPRODUCE
1.  Use dolphin to copy HEIC files from iPhone to a folder in the photo collection
2.  Enable previews in dolphin and navigate to the folder
3.  Open digiKam and navigate to the folder

OBSERVED RESULT
In dolphin, the thumbnails are orientated correctly
In digiKam the thumbnails are 90 or 180 degrees rotated

EXPECTED RESULT
Thumbnails of HEIC files are correctly orientated

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.7
KDE Frameworks Version: 5.109.0
Qt Version: 5.15.10
Graphics Platform: Wayland
Graphics Processor: AMD CEDAR

ADDITIONAL INFORMATION
The rotate button on the thumbnail often rotates it by more than 90 deg
Clicking on a thumbnail with the wrong orientation opens the preview with the correct orientation
Comment 1 Maik Qualmann 2023-09-10 14:19:02 UTC
*** Bug 473396 has been marked as a duplicate of this bug. ***
Comment 2 Maik Qualmann 2023-09-10 14:21:35 UTC
I can't reproduce the problem with sample iPhone files from the web. Please upload a sample image where the problem occurs for you. Which libheif version do you use, please check the digiKam component information.

Maik
Comment 3 Paul Worrall 2023-09-10 16:01:11 UTC
Created attachment 161539 [details]
File with thumbnail rotated 90 counter-clockwise

Image that shows the problem.  The thumbnail in DK is rotated 90 deg counter-clockwise
Comment 4 Paul Worrall 2023-09-10 16:07:18 UTC
libheif 1.16.2-1
Comment 5 Maik Qualmann 2023-09-10 16:19:00 UTC
Thanks for the sample image. The thumbnail and image are displayed correctly aligned here.

I assume that you have activated the display of the image according to Exif information in the digiKam metadata settings under Rotate.

The cause could be the libheif version used. Gwenview requests an aligned image from libheif. digiKam requests an unaligned image from libheif since we rotate himself. There was a libheif version with a bug and the automatic alignment could not be disabled.

But, your libheif version is not affected by this.

Maik
Comment 6 Maik Qualmann 2023-09-10 16:22:22 UTC
Can you please activate internal debugging in the digiKam settings under Miscellaneous->System. Then restart digiKam in the terminal and reread the metadata from the image (Menu->Item). And post the output in the terminal.

Maik
Comment 7 Paul Worrall 2023-09-10 22:28:47 UTC
Created attachment 161547 [details]
My settings under Metadata -> Rotation

These are my settings under metadata -> rotation
Comment 8 Paul Worrall 2023-09-10 22:34:46 UTC
digikam.general: Using  2  CPU core to run threads
digikam.general: Using  1  CPU core to run threads
digikam.general: Creating a metadata task for synchronizing metadata
digikam.general: Action Thread run  1  new jobs
digikam.metaengine: Loading metadata with "Exiv2" backend from "/srv/nethome/photos/Temporary/IMG_1041.HEIC"
digikam.dimg: "/srv/nethome/photos/Temporary/IMG_1041.HEIC" : "HEIF" file identified
digikam.dimg.heif: HEIF image size: ( 3024 x 4032 )
digikam.dimg.heif: Decoded HEIF image properties: size( 4032 x 3024 ), Alpha: false , Color depth : 8
digikam.dimg.heif: HEIF data container: 0x7f5380dcc010
digikam.dimg.heif: HEIC bytes per line: 12096
digikam.dimg.heif: Color bytes depth: 8
digikam.metaengine: DateTime (Exif digitalized): QDateTime(2023-09-04 13:32:30.000 BST Qt::LocalTime)
digikam.metaengine: DateTime (digitization date): QDateTime(2023-09-04 13:32:30.000 BST Qt::LocalTime)
digikam.database: Scanning took 587 ms
digikam.database: Finishing took 13 ms
digikam.geoiface: ----
digikam.general: One job is done
digikam.general: List of Pending Jobs is empty
digikam.general: Event is dispatched to KDE desktop notifier
digikam.general: Cancel Main Thread
digikam.general: Finish Main Thread
digikam.general: Using  2  CPU core to run threads
digikam.general: Action Thread run  1  new jobs
digikam.general: One job is done
digikam.general: Finish Main Thread
Comment 9 Paul Worrall 2023-09-10 22:36:50 UTC
Rereading the metadata from the image causes the thumbnail orientation to correct itself
Comment 10 Maik Qualmann 2023-09-11 10:39:55 UTC
If rereading the metadata helps, the metadata was not fully captured when the file was first scanned. We know the problem from Windows, but we suspect blockades from antivirus software there.
Can you reproduce the problem with a new HEIF file, if so please describe how exactly you import the file into digiKam. Do you copy the file externally into a digiKam album at runtime? Do you then press F5 to update the album?

Maik
Comment 11 Paul Worrall 2023-09-11 12:42:29 UTC
I experience the problem with many HEIC files.

With digiKam _not_ running on my PC, my wife used dolphin to copy the files from her phone into folders on a NAS server which is mounted on my PC using NFS. I have configured digiKam to use these folders as albums (Collection on Network Share).

I then launched digiKam on my PC and on completion of the "Find new items" process the thumbnails were displayed.  I did not press F5 or  Item->Reread Metadata.

digiKam is configured to keep its database in mariadb on the same NAS.
Comment 12 caulier.gilles 2023-10-11 03:41:53 UTC
Paul,

What's about this file using current 8.2.0 AppImage Linux bundle ? It's reproducible ?

https://files.kde.org/digikam/

Thanks in advance

Gilles Caulier
Comment 13 Paul Worrall 2023-10-24 14:07:16 UTC
(In reply to caulier.gilles from comment #12)
> Paul,
> 
> What's about this file using current 8.2.0 AppImage Linux bundle ? It's
> reproducible ?
> 
> https://files.kde.org/digikam/
> 
> Thanks in advance
> 
> Gilles Caulier

Sorry Gilles but I am now unable to reproduce the problem in my Arch-packaged version of DK; marking the bug as resolved.
Regards
Paul