Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Canon lens detection (#2057) #2235

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/canonmn_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2527,6 +2527,13 @@ std::ostream& printCsLensTypeByMetadata(std::ostream& os, const Value& value, co
return printCsLensFFFF(os, value, metadata);
}

// TODO: The lens identification could be improved further:
// 1. RF lenses also set Exif.CanonFi.RFLensType. If a lens cannot be found here then
// the RF mechanism could be used instead.
// 2. Exif.Photo.LensModel and Exif.Canon.LensModel provide a text description of the lens
// (e.g., "RF24-105mm F4-7.1 IS STM" - Note: no manufacturer or space after "RF").
// After parsing, the values could be used to search in the lens array.

// get the values we need from the metadata container
ExifKey lensKey("Exif.CanonCs.Lens");
auto pos = metadata->findKey(lensKey);
Expand Down Expand Up @@ -2829,6 +2836,8 @@ float canonEv(int64_t val) {
frac = 64.0F / 3;
} else if ((val == 160) && (frac == 0x08)) { // for Sigma f/6.3 lenses that report f/6.2 to camera
frac = 30.0F / 3;
} else if ((val == 160) && (frac == 0x18)) { // for Canon F4-7.1 lens that reports max aperture as f/7.3
frac = 21.0F;
}
return sign * (val + frac) / 32.0F;
}
Expand Down
Binary file added test/data/issue_2057_poc1.exv
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Exif.CanonSi.AEBBracketValue Short 1 0 0
Exif.CanonSi.ControlMode Short 1 1 1
Exif.CanonSi.SubjectDistance Short 1 0 0 m
Exif.CanonSi.ApertureValue Short 1 148 F5
Exif.CanonSi.ShutterSpeedValue Short 1 184 1/54 s
Exif.CanonSi.ShutterSpeedValue Short 1 184 1/50 s
Exif.CanonSi.MeasuredEV2 Short 1 123 9.38
Exif.CanonSi.BulbDuration Short 1 0 0
Exif.CanonSi.CameraType Short 1 248 EOS High-end
Expand Down
490 changes: 490 additions & 0 deletions test/data/test_reference_files/issue_2057_poc1.exv.out

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions tests/bugfixes/github/test_issue_2057.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-

from system_tests import CaseMeta, path

class AddLens_Canon_RF_24_105mm_F4_7_1_IS_STM(metaclass=CaseMeta):
"""
Regression test for the bug described in:
https://github.com/Exiv2/exiv2/issues/2057
"""
url = "https://github.com/Exiv2/exiv2/issues/2057"

filename = path("$data_path/issue_2057_poc1.exv")
commands = ["$exiv2 --Print kyyvt --key Exif.CanonCs.LensType $filename"]
stderr = [""]
stdout = ["""Exif.CanonCs.LensType Short 61182 Canon RF 24-105mm F4-7.1 IS STM
"""]
retval = [0]