Skip to content

Commit 8d36bcc

Browse files
Update Canon decoder for lens detection (#2057)
The `Canon RF 24-105 F4-7.1 IS STM` lens is reported as using an `Exif.CanonCs.MaxAperture` of `F7.3` instead of `F7.1`. As a result, the translation of `Exif.CanonCs.LensType` is missing. Fix updates the `CanonEV()` decode function to provide the correct value.
1 parent 315ae6d commit 8d36bcc

File tree

5 files changed

+517
-1
lines changed

5 files changed

+517
-1
lines changed

src/canonmn_int.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -2527,6 +2527,13 @@ std::ostream& printCsLensTypeByMetadata(std::ostream& os, const Value& value, co
25272527
return printCsLensFFFF(os, value, metadata);
25282528
}
25292529

2530+
// TODO: The lens identification could be improved further:
2531+
// 1. RF lenses also set Exif.CanonFi.RFLensType. If a lens cannot be found here then
2532+
// the RF mechanism could be used instead.
2533+
// 2. Exif.Photo.LensModel and Exif.Canon.LensModel provide a text description of the lens
2534+
// (e.g., "RF24-105mm F4-7.1 IS STM" - Note: no manufacturer or space after "RF").
2535+
// After parsing, the values could be used to search in the lens array.
2536+
25302537
// get the values we need from the metadata container
25312538
ExifKey lensKey("Exif.CanonCs.Lens");
25322539
auto pos = metadata->findKey(lensKey);
@@ -2829,6 +2836,8 @@ float canonEv(int64_t val) {
28292836
frac = 64.0F / 3;
28302837
} else if ((val == 160) && (frac == 0x08)) { // for Sigma f/6.3 lenses that report f/6.2 to camera
28312838
frac = 30.0F / 3;
2839+
} else if ((val == 160) && (frac == 0x18)) { // for Canon F4-7.1 lens that reports max aperture as f/7.3
2840+
frac = 21.0F;
28322841
}
28332842
return sign * (val + frac) / 32.0F;
28342843
}

test/data/issue_2057_poc1.exv

1.16 MB
Binary file not shown.

test/data/test_reference_files/Sigma_50mm_F1.4_DG_HSM_A_for_EOS.exv.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Exif.CanonSi.AEBBracketValue Short 1 0 0
8787
Exif.CanonSi.ControlMode Short 1 1 1
8888
Exif.CanonSi.SubjectDistance Short 1 0 0 m
8989
Exif.CanonSi.ApertureValue Short 1 148 F5
90-
Exif.CanonSi.ShutterSpeedValue Short 1 184 1/54 s
90+
Exif.CanonSi.ShutterSpeedValue Short 1 184 1/50 s
9191
Exif.CanonSi.MeasuredEV2 Short 1 123 9.38
9292
Exif.CanonSi.BulbDuration Short 1 0 0
9393
Exif.CanonSi.CameraType Short 1 248 EOS High-end

test/data/test_reference_files/issue_2057_poc1.exv.out

+490
Large diffs are not rendered by default.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from system_tests import CaseMeta, path
4+
5+
class AddLens_Canon_RF_24_105mm_F4_7_1_IS_STM(metaclass=CaseMeta):
6+
"""
7+
Regression test for the bug described in:
8+
https://github.com/Exiv2/exiv2/issues/2057
9+
"""
10+
url = "https://github.com/Exiv2/exiv2/issues/2057"
11+
12+
filename = path("$data_path/issue_2057_poc1.exv")
13+
commands = ["$exiv2 --Print kyyvt --key Exif.CanonCs.LensType $filename"]
14+
stderr = [""]
15+
stdout = ["""Exif.CanonCs.LensType Short 61182 Canon RF 24-105mm F4-7.1 IS STM
16+
"""]
17+
retval = [0]

0 commit comments

Comments
 (0)