Bug 342931

Summary: Wrong apect ratio in item properties and in item view
Product: [Applications] digikam Reporter: Stas <stas.kazmin>
Component: Metadata-EngineAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: caulier.gilles, metzpinguin
Priority: NOR    
Version: 4.8.0   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 4.9.0
Attachments: aspectratio.patch
aspectratio2.patch

Description Stas 2015-01-16 20:19:37 UTC
Hello, I have found that in item properties and also when showing the aspect ratio in the icon view, the aspect ratio is always 3:2. The search option works however. So it is a error in displaying the ratio.

I have researched a little bit in the code and have found the error:
in: /core/libs/imageproperties/imagepropertiestab.cpp
line: 949
in function: ImagePropertiesTab::aspectRatioToString()
the following can be found: doubleToHumanReadableFraction((double)nw / (double)nh, &num, &den);
however the function doubleToHumanReadableFraction has 4 parameters.
Changing it to: doubleToHumanReadableFraction((double)nw / (double)nh, &num, &den, 10);
solves the problem both in item properties and in icon view.

I would wish that you change it in the next version or on git. But I do not know whether 10 is the best parameter here.

Thanks for great software anyway.

Reproducible: Always
Comment 1 Maik Qualmann 2015-01-18 17:12:43 UTC
Created attachment 90494 [details]
aspectratio.patch

I think a value of 4 is enough with this function. Here is the patch.

Maik
Comment 2 caulier.gilles 2015-01-18 17:29:01 UTC
Git commit 76eee521045ad6d577a08c7afec292d8b1d99a0e by Gilles Caulier.
Committed on 18/01/2015 at 17:25.
Pushed by cgilles into branch 'master'.

apply patch #90494 from Maik Quallmann to limit decimal precision to show aspect ratio value on image properties and icon-view.
FIXED-IN: 4.7.0

M  +2    -2    libs/imageproperties/imagepropertiestab.cpp
M  +1    -1    libs/imageproperties/imagepropertiestab.h

http://commits.kde.org/digikam/76eee521045ad6d577a08c7afec292d8b1d99a0e
Comment 3 caulier.gilles 2015-01-18 17:30:46 UTC
Git commit 68d118a6b7a87632cc11d6e2b7e65c878d9ebc19 by Gilles Caulier.
Committed on 18/01/2015 at 17:30.
Pushed by cgilles into branch 'frameworks'.

backport commit #76eee521045ad6d577a08c7afec292d8b1d99a0e from git/master to frameworks branch

M  +1    -1    libs/imageproperties/imagepropertiestab.cpp

http://commits.kde.org/digikam/68d118a6b7a87632cc11d6e2b7e65c878d9ebc19
Comment 4 Stas 2015-03-08 14:45:17 UTC
Hello, I have found out that the value of 4 is not enough for this function. With this value videos are shown to be 7:4 and not 16:9. Please check that and change the value (I have 10 but please think of what value is needed to get all "standard" aspect ratios right).

Thanks
Comment 5 Maik Qualmann 2015-03-08 19:23:32 UTC
Created attachment 91495 [details]
aspectratio2.patch

Yes Stas, I have not previously it with 16: 9 tested, we increase to 10. Thank you!

Maik
Comment 6 caulier.gilles 2015-03-08 20:17:34 UTC
Git commit 52dc2861efca3d8deda9fe20fefc46e85029e484 by Gilles Caulier.
Committed on 08/03/2015 at 20:13.
Pushed by cgilles into branch 'master'.

apply patch #91495 from Maik Qualmann to fix apect ration computation in image properties with 16:9 rounding

M  +2    -1    NEWS
M  +1    -1    libs/imageproperties/imagepropertiestab.cpp

http://commits.kde.org/digikam/52dc2861efca3d8deda9fe20fefc46e85029e484

diff --git a/NEWS b/NEWS
index 1d5e9a0..8190592 100644
--- a/NEWS
+++ b/NEWS
@@ -11,5 +11,6 @@ BUGFIXES FROM KDE BUGZILLA (https://www.digikam.org/changelog):
 003 ==> 338753 - Exif ImageDescription field is being used incorrectly.
 004 ==> 330224 - Add collection from network share is silently ignored [patch].
 005 ==> 344699 - Maintenance is using the wrong face data management [patch].
-006 ==>
+006 ==> 342931 - Wrong apect ratio in item properties and in item view.
+007 ==>

diff --git a/libs/imageproperties/imagepropertiestab.cpp b/libs/imageproperties/imagepropertiestab.cpp
index 203ee47..9be90bc 100644
--- a/libs/imageproperties/imagepropertiestab.cpp
+++ b/libs/imageproperties/imagepropertiestab.cpp
@@ -946,7 +946,7 @@ bool ImagePropertiesTab::aspectRatioToString(int width, int height, QString& arS
     }

     long   num=0, den=0;
-    doubleToHumanReadableFraction((double)nw / (double)nh, &num, &den, 4);
+    doubleToHumanReadableFraction((double)nw / (double)nh, &num, &den, 10);

     const QString awidth  = QString::number(num);
     const QString aheight = QString::number(den);
Comment 7 caulier.gilles 2015-03-08 20:19:56 UTC
Git commit 74d1dbdb08874cb3649f59c6c08cedeb79741f29 by Gilles Caulier.
Committed on 08/03/2015 at 20:16.
Pushed by cgilles into branch 'frameworks'.

backport commit #52dc2861efca3d8deda9fe20fefc46e85029e484 from git/master to frameworks branch

M  +2    -2    libs/imageproperties/imagepropertiestab.cpp

http://commits.kde.org/digikam/74d1dbdb08874cb3649f59c6c08cedeb79741f29