Skip to content

Commit f5e3712

Browse files
committed
Improve detection of Canon lenses with TC
Lenses with and without a TC may share the same lens ID. Prefer entries that explicitly mention the TC.
1 parent b6d0001 commit f5e3712

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/canonmn_int.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,17 +1952,26 @@ namespace Exiv2 {
19521952

19531953
extractLensFocalLength(ltfl, metadata);
19541954
if (ltfl.focalLengthMax_ == 0.0) return os << value;
1955-
convertFocalLength(ltfl, 1.0); // just lens
1956-
const TagDetails* td = find(canonCsLensType, ltfl);
1957-
if (!td) {
1958-
convertFocalLength(ltfl, 1.4); // lens + 1.4x TC
1959-
td = find(canonCsLensType, ltfl);
1960-
if (!td) {
1961-
convertFocalLength(ltfl, 2.0); // lens + 2x TC
1955+
1956+
const TagDetails* td;
1957+
const double factors[] = {1.0, 1.4, 2.0};
1958+
for (const double &factor : factors)
1959+
{
1960+
convertFocalLength(ltfl, factor);
1961+
1962+
std::ostringstream oss;
1963+
oss << std::setprecision(2);
1964+
oss << factor << "x";
1965+
1966+
ltfl.maxAperture_ = oss.str();
19621967
td = find(canonCsLensType, ltfl);
1963-
if (!td) return os << value;
1964-
}
1968+
if (td) break;
1969+
1970+
ltfl.maxAperture_ = "";
1971+
td = find(canonCsLensType, ltfl);
1972+
if (td) break;
19651973
}
1974+
if (!td) return os << value;
19661975
return os << td->label_;
19671976
}
19681977

0 commit comments

Comments
 (0)