Bug 455876 - Handling of image orientation in modern image formats using ExifTool
Summary: Handling of image orientation in modern image formats using ExifTool
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-Orientation (show other bugs)
Version: 7.7.0
Platform: unspecified All
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-24 08:37 UTC by dnovomesky
Modified: 2022-06-26 11:48 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 7.8.0


Attachments
Test image in JPEG XL format (2.16 MB, image/jxl)
2022-06-24 08:37 UTC, dnovomesky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dnovomesky 2022-06-24 08:37:29 UTC
Created attachment 150112 [details]
Test image in JPEG XL format

Hello,

digiKam rotates images images according orientation in Exif metadata. That's how it must be done for old JPG format.

However, JPEG XL, HEIF, AVIF have rotation stored inside the format and if there is any orientation in the Exif metadata, it is not longer relevant (it refers just to the source/input image prior encoding).
The best handling of these formats it is to ignore rotations in Exif metadata.

"The Exif orientation should be ignored by applications; the JPEG XL codestream orientation takes precedence and libjxl will by default apply the correct orientation automatically"
https://github.com/libjxl/libjxl/blob/b7961e1318634a95c7d689ec340dbad8a42d4ed4/lib/include/jxl/decode.h#L1251

However, in some cases, there could be Thumbnail in JXL file stored in Exif metadata. If you are reading the Thumbnail, it must be still rotated according the Exif orientation.

The attached image (IMG_20220406_134135.jxl) is now rotated in digiKam, but the preview is OK. Correct display is without rotation and to keep rotation of the Exif thumbnail according the Exif.
Comment 1 caulier.gilles 2022-06-24 09:10:57 UTC
Exiv2 support for these format is apain.

The solution is to use ExifTool instead. We needs to check if ExifTool handle properly this orientation info from these kind of files.

Gilles Caulier
Comment 2 Maik Qualmann 2022-06-24 09:56:16 UTC
With libheif it's a bug that was fixed in the git/master version. The current libheif only rotates the image automatically if we would set the flag. So you can't say in general that an aligned image is always returned.

Maik
Comment 3 dnovomesky 2022-06-24 10:44:26 UTC
It is important to know how each library/plug-in returns the data.

Well, with libheif you can now choose if to apply transformations on library's side or to do it on application's side.
Values Clean Aperture (crop operation) can be read via exiftool, rotate and mirror must be applied afterwards.
I think it is more convenient to let libheif to do it all.

The kimg_avif and kimg_jxl Qt plug-ins return final result, no need to apply further transformation.
Comment 4 Maik Qualmann 2022-06-24 10:46:12 UTC
Git commit ed87eb7c86d7a47a83cf0bc3ffaa426e3b10a893 by Maik Qualmann.
Committed on 24/06/2022 at 10:45.
Pushed by mqualmann into branch 'qt5-maintenance'.

disable auto transformation for the QImage loader
FIXED-IN: 7.8.0

M  +2    -1    NEWS
M  +1    -0    core/dplugins/dimg/qimage/dimgqimageloader.cpp

https://invent.kde.org/graphics/digikam/commit/ed87eb7c86d7a47a83cf0bc3ffaa426e3b10a893
Comment 5 Maik Qualmann 2022-06-24 11:34:17 UTC
A note for the suggestion to let the image library do the transformation. This is bad for digiKam because then we get a problem with face regions alignment. We have to take this into account even with RAW files. There is no standard as to whether the face regions were saved to the aligned or unaligned image. If the metadata is no longer in sync after loading the image, we have a problem.

Maik
Comment 6 Maik Qualmann 2022-06-24 17:54:46 UTC
The QImageReader ignores the disabled transform option.

Maik
Comment 7 Maik Qualmann 2022-06-26 11:48:05 UTC
Git commit 48129d7a834f1deff5f93df192050b6d55563ea8 by Maik Qualmann.
Committed on 26/06/2022 at 11:47.
Pushed by mqualmann into branch 'master'.

disable rotation for selected QImage formats
FIXD-IN: 8.0.0

M  +9    -3    core/dplugins/dimg/qimage/dimgqimageloader_load.cpp

https://invent.kde.org/graphics/digikam/commit/48129d7a834f1deff5f93df192050b6d55563ea8