Skip to content

Commit

Permalink
Improve focus distance precision for Nikon Z
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilos committed Aug 8, 2023
1 parent 6ea6e2c commit 52a6f63
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/nikonmn_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1719,8 +1719,8 @@ constexpr TagInfo Nikon3MakerNote::tagInfoLd4_[] = {
printApertureLd4},
{60, "FocalLength2", N_("Focal Length 2"), N_("Focal length 2"), IfdId::nikonLd4Id, SectionId::makerTags,
unsignedShort, 1, printFocalLd4},
{79, "FocusDistance2", N_("Focus Distance 2"), N_("Focus distance 2"), IfdId::nikonLd4Id, SectionId::makerTags,
unsignedByte, 1, printFocusDistance},
{78, "FocusDistance2", N_("Focus Distance 2"), N_("Focus distance 2"), IfdId::nikonLd4Id, SectionId::makerTags,
unsignedShort, 1, printFocusDistanceLd4},
// End of list marker
{0xffff, "(UnknownNikonLd4Tag)", "(UnknownNikonLd4Tag)", N_("Unknown Nikon Lens Data 3 Tag"), IfdId::nikonLd4Id,
SectionId::makerTags, unsignedByte, 1, printValue},
Expand Down Expand Up @@ -3963,4 +3963,20 @@ std::ostream& Nikon3MakerNote::printFocalLd4(std::ostream& os, const Value& valu
return os;
}

std::ostream& Nikon3MakerNote::printFocusDistanceLd4(std::ostream& os, const Value& value, const ExifData*) {
std::ios::fmtflags f(os.flags());
if (value.count() != 1 || value.typeId() != unsignedByte) {
os << "(" << value << ")";
os.flags(f);
return os;
}
double dist = 0.01 * pow(10.0, value.toInt64() / (256.0 * 40.0));
std::ostringstream oss;
oss.copyfmt(os);
os << std::fixed << std::setprecision(2) << dist << " m";
os.copyfmt(oss);
os.flags(f);
return os;
}

} // namespace Exiv2::Internal
2 changes: 2 additions & 0 deletions src/nikonmn_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class Nikon3MakerNote {
static std::ostream& printLensId4ZMount(std::ostream& os, const Value& value, const ExifData*);
//! Print focus distance
static std::ostream& printFocusDistance(std::ostream& os, const Value& value, const ExifData*);
//! Print focus distance for new LensData as used for e.g. Nikon Z 6/7
static std::ostream& printFocusDistanceLd4(std::ostream& os, const Value& value, const ExifData*);
//! Print lens aperture value
static std::ostream& printAperture(std::ostream& os, const Value& value, const ExifData*);
//! Print lens aperture value for new LensData as used for e.g. Nikon Z 6/7
Expand Down

0 comments on commit 52a6f63

Please sign in to comment.