Bug 312549

Summary: showfoto does not correctly rotate images in the main view
Product: [Applications] digikam Reporter: Achim Herwig <achim.herwig>
Component: Showfoto-PluginsAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: major CC: caulier.gilles, kphoto2, marcel.wiesweg
Priority: NOR    
Version: 2.9.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In: 7.6.0
Sentry Crash Report:
Attachments: after rotation in showfoto, photo is incorrect in preview and in konqueror
example landscape photo
a better example

Description Achim Herwig 2013-01-03 16:14:43 UTC
Created attachment 76166 [details]
after rotation in showfoto, photo is incorrect in preview and in konqueror

After the upgrade to showfoto 2.9.0, my portrait mode photos are shown rotated in the main view and correct in the preview pane. 

When I rotate the photos manually, they are shown correctly in  the main view, but rotated in the preview pane. When I then save them, they are shown rotated in konqueror thumbnail preview and in gwenview. See attachment.

I tried to change the behavior by toggling the application setting metadata/ Rotate according to exif data, but to no avail.
Comment 1 ar@home 2013-01-20 18:13:35 UTC
Same her with 2.8.0 from kubuntu 12.10. 
No problems in digikam editor.
Comment 2 ar@home 2013-01-22 11:55:35 UTC
(In reply to comment #1)
> Same her with 2.8.0 from kubuntu 12.10. 
> No problems in digikam editor.

And also in 2.6.0 (Debian 2.6.0-1+b2).
Comment 3 ar@home 2013-02-24 13:38:37 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > Same her with 2.8.0 from kubuntu 12.10. 
> > No problems in digikam editor.
> 
> And also in 2.6.0 (Debian 2.6.0-1+b2).

as well as in 3.0.0 (Ubuntu Beta) :-(
Any idea when the error occurred the first time? (irc 1.9 was OK).
Comment 4 caulier.gilles 2013-02-24 13:47:03 UTC
Exiv2 shared lib is used here to get image orientation from image metadata.

Gilles Caulier
Comment 5 ar@home 2013-02-24 14:54:57 UTC
(In reply to comment #4)
> Exiv2 shared lib is used here to get image orientation from image metadata.
> 
> Gilles Caulier

running exiv2 on a portrait jpeg gives 

$ exiv2 -pv e2224516.jpg | grep Orientation
0x0112 Image        Orientation                 Short       1  6

(image _is_ rotated 90 degrees)

In the thumb bar the preview is shown correctly but in the edit area the image is rotated to the left.

If I change the orientation by issuing

$ exiv2 -M"set Exif.Image.Orientation 1" e2224516.jpg

the image is shown in both the thumb bar and the edit area rotated to the left.

So it seems the exif information is evaluated correctly only  for the preview.
Comment 6 ar@home 2013-02-26 14:24:02 UTC
The slide show is shown correctly; so it seems that the exifOrientation information is not applied to the editor window.
Comment 7 ar@home 2013-03-01 06:28:01 UTC
So I played a bit with a debugger and found:

- creation of thumbnails: exif orientation is queried and used
- slideshow: exif orientation is queried and used
- called from digikam (tools->editor): exif orientation is queried (from db) and used
- called standalone (with filename, thumbbar hidden): exif info is not queried, orientation is always ignored...
Comment 8 caulier.gilles 2013-03-01 06:41:10 UTC
There is an option in Shwofoto Settings pannel, into Metadata/Behavior section. It's turned on ?

Gilles Caulier
Comment 9 ar@home 2013-03-01 07:23:49 UTC
(In reply to comment #8)
> There is an option in Shwofoto Settings pannel, into Metadata/Behavior
> section. It's turned on ?
> 
> Gilles Caulier

I've tried both settings (on/off); it makes no difference (see also Achim's post #1, last line). 

Because debugging a unknown, mutlithreaded C++ application is a pain, I stopped for the moment. It looks like there's a point in loadsavethread and related methods where a decision is made whether to query exif infos or not (e. g. do we have db infos? Which preview description type etc),
 
If we find the version when this behavior changed (1.9 is working fine) we might get the bug. 

Andreas
Comment 10 caulier.gilles 2013-03-01 07:51:48 UTC
>e. g. do we have db infos?

Showfoto do not use a DB. It take Exif orientation flag info from file metadata and that all...

Can you share some images which have the problem in your computer

Gilles Caulier
Comment 11 ar@home 2013-03-01 08:16:38 UTC
Created attachment 77656 [details]
example landscape photo
Comment 12 ar@home 2013-03-01 08:17:07 UTC
(In reply to comment #10)
> >e. g. do we have db infos?
> 
> Showfoto do not use a DB. It take Exif orientation flag info from file
> metadata and that all...
> 
> Can you share some images which have the problem in your computer
> 
> Gilles Caulier

I know that showfoto as a standalone application doesn't use a db but digikam does and if the component is called as the digikam editor information from the digikam-db is used. Called as showfoto it should read the exifs an it does so for the thumbs in the thumbbar and for the slideshow but not for the image in the main view.

You'll find a landscape image attached (exif orientation 6)
Andreas
Comment 13 ar@home 2013-03-01 08:37:48 UTC
Created attachment 77660 [details]
a better example
Comment 14 ar@home 2013-03-04 08:20:11 UTC
(In reply to comment #9)

> If we find the version when this behavior changed (1.9 is working fine) we
> might get the bug. 
> 

The last version working fine is 2.5.0. 
The bug is present from 2.6.0beta1 on (introducing kexiv2 access?).

Andreas
Comment 15 caulier.gilles 2013-03-04 08:34:31 UTC
To localize where is the bug, please identify which library is used with digiKam 2.5.0 and 2.6.0 :

- libkexiv2
- Exiv2

Gilles Caulier
Comment 16 ar@home 2013-03-04 11:00:29 UTC
(In reply to comment #15)
> To localize where is the bug, please identify which library is used with
> digiKam 2.5.0 and 2.6.0 :
> 
> - libkexiv2
> - Exiv2
> 
> Gilles Caulier

For both versions:

ldd core/showfoto/showfoto | grep exiv
	libkexiv2.so.10 => /usr/lib/libkexiv2.so.10 (0xb7176000)
	libexiv2.so.12 => /usr/lib/libexiv2.so.12 (0xb3db0000)

Debugging showfoto with breakpoints at
LoadSaveThread::exifOrientation and LoadSaveThread::exifRotate

shows:

If load the file from command line with the thumbbar turned off both methods are never called. On Turning the thumbbar on the application stops at breakpoints and the thumbnail show a correct orientation while the main view stays in landscape mode.


Andreas
Comment 17 ar@home 2013-03-12 13:37:49 UTC
(In reply to comment #16)
> 	libkexiv2.so.10 => /usr/lib/libkexiv2.so.10 (0xb7176000)
> 	libexiv2.so.12 => /usr/lib/libexiv2.so.12 (0xb3db0000)
>

libexiv2 from debian libexiv2-12 (0.23-1)
libkexiv2 from debian libkexiv2-10 (4.8.4-1)
 
 Andreas
Comment 18 ar@home 2013-03-15 15:16:39 UTC
Looking closer I found the exifRotate property never is set since 2.6 (defaults to false).

The lines in showfoto.cpp (2.5.0) which do the trick are now commented out:

562    bool exifRotate = group.readEntry("EXIF Rotate", true);
563   m_canvas->setExifOrient(exifRotate);

When I reactivate these, rotated images are shown correctly (tested with git-code).

Andreas
Comment 19 caulier.gilles 2013-03-15 16:23:27 UTC
Thanks to investigate. This have been introduced by this commit from Marcel, probably by error :

https://projects.kde.org/projects/extragear/graphics/digikam/repository/revisions/77f7fd8a6413e326026ff86bf4bc7e98ee9c498d

Code change :

https://projects.kde.org/projects/extragear/graphics/digikam/repository/revisions/77f7fd8a6413e326026ff86bf4bc7e98ee9c498d/diff/showfoto/main/showfoto.cpp

Marcel, these lines can be uncommented safetly ?

Gilles Caulier
Comment 20 Marcel Wiesweg 2013-03-17 13:50:00 UTC
The correct way would be to set up the MetadataSettings correctly. exifRotate = true is the default value, which means at some place in showfoto, this setting is changed, or the setup is not read correctly. We need to investigate.
Comment 21 caulier.gilles 2013-03-18 09:12:20 UTC
Git commit f14412312d4aa8c1ab3ac75474e05cc6b723257a by Gilles Caulier.
Committed on 18/03/2013 at 10:09.
Pushed by cgilles into branch 'master'.

Initialize MetadataSettings at showfoto startup
Move canvas Exif autorotate handing in applyStandardSettings()
FIXED-IN : 3.2.0

M  +1    -1    showfoto/main/main.cpp
M  +15   -18   showfoto/main/showfoto.cpp
M  +1    -1    showfoto/main/showfoto.h
M  +9    -2    utilities/imageeditor/editor/editorwindow.cpp
M  +1    -1    utilities/imageeditor/editor/editorwindow.h
M  +1    -5    utilities/imageeditor/main/imagewindow.cpp

http://commits.kde.org/digikam/f14412312d4aa8c1ab3ac75474e05cc6b723257a
Comment 22 ar@home 2013-03-18 12:46:04 UTC
Great!

I manually applied this to 2.6.0beta1 ... works fine. So patching other versions with a slight jitter should be simple.

Thanks
Andreas