Format photo exposure time as rational when applicable
ClosedPublic

Authored by astippich on Jun 2 2019, 8:12 AM.

Details

Summary

If value is below 0.3, format the output as
rational which is commonly used in photography.
Value is computed from the double input value.

CCBUG: 343273

Diff Detail

Repository
R286 KFileMetaData
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
astippich created this revision.Jun 2 2019, 8:12 AM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptJun 2 2019, 8:12 AM
Restricted Application added subscribers: Baloo, kde-frameworks-devel. · View Herald Transcript
astippich requested review of this revision.Jun 2 2019, 8:12 AM

Ideally it would be possible to store rationals in KFM and Baloo, but this is probably a lot of work. The computation here is quite simple

astippich edited the summary of this revision. (Show Details)Jun 2 2019, 8:27 AM
astippich updated this revision to Diff 59009.Jun 2 2019, 8:51 AM
  • check for zero
bruns added inline comments.Jun 2 2019, 9:41 AM
autotests/propertyinfotest.cpp
134

Please add two more testcases for exposure bias:

  1. negative bias
  2. abs(bias) > 1
src/formatstrings.cpp
161

Rational, without 'e'

167

This will give a wrong result (1/2) for 0.4 seconds.

bruns requested changes to this revision.Jun 2 2019, 9:41 AM
This revision now requires changes to proceed.Jun 2 2019, 9:41 AM
astippich updated this revision to Diff 59028.Jun 2 2019, 6:53 PM
  • implement feedback
astippich marked 2 inline comments as done.Jun 2 2019, 6:55 PM
astippich added inline comments.
src/formatstrings.cpp
167

I changed the threshold to be lower than that as a workaround.
My impression was that only 1 over something rationals are used, this computation will of course fail for all other cases...

astippich planned changes to this revision.Jun 3 2019, 2:40 PM
bruns added inline comments.Jun 3 2019, 6:02 PM
src/formatstrings.cpp
167

For a chart of typical exposure times, see https://www.borrowlenses.com/blog/shutter-speed-chart/

I can confirm for my Canon SLR there is at one more value which would give a deviating result, 0.3 seconds (!= 1/3s). 0.25 seconds is shown as 1/4s.

astippich updated this revision to Diff 59221.Jun 5 2019, 7:54 PM
  • only format exposure time
astippich added inline comments.Jun 5 2019, 7:58 PM
src/formatstrings.cpp
167

Thanks for the information. From what I've read, for the exposure time the right threshold is 0.3, and the value is always a rational of 1/x.
The story seems to be different for the bias, though, so I've excluded it here.

astippich updated this revision to Diff 59222.Jun 5 2019, 7:59 PM
  • add unit
astippich retitled this revision from Format photo exposure time and bias as rational to Format photo exposure time as rational when applicable.Jun 5 2019, 8:02 PM
astippich edited the summary of this revision. (Show Details)
astippich added inline comments.
src/formatstrings.cpp
167

Computation now also falls back to decimal representation if it cannot be represented with a 1/x rational

astippich updated this revision to Diff 59224.Jun 5 2019, 8:04 PM
  • rename format function
bruns accepted this revision.Jun 8 2019, 5:31 PM
This revision is now accepted and ready to land.Jun 8 2019, 5:31 PM
This revision was automatically updated to reflect the committed changes.