Skip to content

Commit

Permalink
Merge pull request Exiv2#2760 from norbertwg/translation-of-value-0-i…
Browse files Browse the repository at this point in the history
…n-Exif.NikonLd4.MaxAperture

Nikon printApertureLd4 translate value 0 to n/a
  • Loading branch information
kmilos authored Sep 19, 2023
2 parents c54afb5 + ffacfda commit 1ae47bc
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 11 deletions.
33 changes: 28 additions & 5 deletions src/nikonmn_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ std::ostream& Nikon3MakerNote::print0x0088(std::ostream& os, const Value& value,
// But when actually in "Single area, Center" this can mean
// that focus was not found (try this in AF-C mode)
// TODO: handle the meaningful case (interacts with other fields)
os << "N/A";
os << _("n/a");
return os;
}

Expand Down Expand Up @@ -3263,6 +3263,10 @@ std::ostream& Nikon3MakerNote::printFocusDistance(std::ostream& os, const Value&
os.flags(f);
return os;
}
auto temp = value.toInt64();
if (temp == 0)
return os << _("n/a");

double dist = 0.01 * pow(10.0, value.toInt64() / 40.0);
std::ostringstream oss;
oss.copyfmt(os);
Expand All @@ -3279,6 +3283,10 @@ std::ostream& Nikon3MakerNote::printAperture(std::ostream& os, const Value& valu
os.flags(f);
return os;
}
auto temp = value.toInt64();
if (temp == 0)
return os << _("n/a");

double aperture = pow(2.0, value.toInt64() / 24.0);
std::ostringstream oss;
oss.copyfmt(os);
Expand All @@ -3292,6 +3300,10 @@ std::ostream& Nikon3MakerNote::printFocal(std::ostream& os, const Value& value,
if (value.count() != 1 || value.typeId() != unsignedByte) {
return os << "(" << value << ")";
}
auto temp = value.toInt64();
if (temp == 0)
return os << _("n/a");

double focal = 5.0 * pow(2.0, value.toInt64() / 24.0);
std::ostringstream oss;
oss.copyfmt(os);
Expand Down Expand Up @@ -3839,16 +3851,16 @@ std::ostream& Nikon3MakerNote::printPictureControl(std::ostream& os, const Value
oss.copyfmt(os);
switch (pcval) {
case 0:
os << "Normal";
os << _("Normal");
break;
case 127:
os << "n/a";
os << _("n/a");
break;
case -127:
os << "User";
os << _("User");
break;
case -128:
os << "Auto";
os << _("Auto");
break;
default:
os << pcval;
Expand Down Expand Up @@ -3944,6 +3956,9 @@ std::ostream& Nikon3MakerNote::printApertureLd4(std::ostream& os, const Value& v
if (value.count() != 1 || value.typeId() != unsignedShort) {
return os << "(" << value << ")";
}
auto temp = value.toInt64();
if (temp == 0)
return os << _("n/a");

double aperture = pow(2.0, value.toInt64() / 384.0 - 1.0);
std::ostringstream oss;
Expand All @@ -3956,6 +3971,10 @@ std::ostream& Nikon3MakerNote::printFocalLd4(std::ostream& os, const Value& valu
if (value.count() != 1 || value.typeId() != unsignedShort) {
return os << "(" << value << ")";
}
auto temp = value.toInt64();
if (temp == 0)
return os << _("n/a");

std::ostringstream oss;
oss.copyfmt(os);
os << std::fixed << std::setprecision(1) << value.toInt64() << " mm";
Expand All @@ -3967,6 +3986,10 @@ std::ostream& Nikon3MakerNote::printFocusDistanceLd4(std::ostream& os, const Val
if (value.count() != 1 || value.typeId() != unsignedShort) {
return os << "(" << value << ")";
}
auto temp = value.toInt64();
if (temp == 0)
return os << _("n/a");

double dist = 0.01 * pow(10.0, (value.toInt64() / 256.0) / 40.0);
std::ostringstream oss;
oss.copyfmt(os);
Expand Down
Binary file added test/data/NikonZ6.exv
Binary file not shown.
8 changes: 4 additions & 4 deletions test/data/test_reference_files/CH0_0174.exv.out
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ Exif.NikonLd4.MaxApertureAtMaxFocal Byte 1 36 F2.8
Exif.NikonLd4.MCUVersion Byte 1 123 123
Exif.NikonLd4.EffectiveMaxAperture Byte 1 36 F2.8
Exif.NikonLd4.LensID Short 1 0 0
Exif.NikonLd4.MaxAperture Short 1 0 F0.5
Exif.NikonLd4.FNumber Short 1 0 F0.5
Exif.NikonLd4.FocalLength2 Short 1 0 0 mm
Exif.NikonLd4.FocusDistance2 Short 1 0 0.01 m
Exif.NikonLd4.MaxAperture Short 1 0 n/a
Exif.NikonLd4.FNumber Short 1 0 n/a
Exif.NikonLd4.FocalLength2 Short 1 0 n/a
Exif.NikonLd4.FocusDistance2 Short 1 0 n/a
Exif.Nikon3.RawImageCenter Short 2 2274 1515 2274 1515
Exif.Nikon3.RetouchHistory Short 10 0 0 0 0 0 0 0 0 0 0 None
Exif.Nikon3.ShutterCount Long 1 174 174
Expand Down
200 changes: 200 additions & 0 deletions test/data/test_reference_files/NikonZ6.exv.out

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/bash_tests/test_easyaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ class NikonLd4LensIDx(metaclass=CaseMeta):
Aperture value ( ) :
Brightness value ( ) :
Exposure bias (Exif.Photo.ExposureBiasValue ) : 0 EV
Max aperture value (Exif.NikonLd4.MaxAperture ) : F0.5
Max aperture value (Exif.NikonLd4.MaxAperture ) : n/a
Subject distance (Exif.NikonLd4.FocusDistance ) : 2.66 m
Light source (Exif.Photo.LightSource ) : Unknown
Flash (Exif.Photo.Flash ) : No flash
Expand Down
2 changes: 1 addition & 1 deletion tests/bugfixes/github/test_pr_1437.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Nikon_LensData8(metaclass=system_tests.CaseMeta):
Exif.NikonLd4.MaxApertureAtMaxFocal Byte 1 F2.8
Exif.NikonLd4.EffectiveMaxAperture Byte 1 F2.8
Exif.NikonLd4.LensID Short 1 0
Exif.NikonLd4.MaxAperture Short 1 F0.5
Exif.NikonLd4.MaxAperture Short 1 n/a
Exif.Nikon3.ShutterCount Long 1 174
Exif.Photo.LensSpecification Rational 4 70-200mm F2.8
Exif.Photo.LensMake Ascii 6
Expand Down

0 comments on commit 1ae47bc

Please sign in to comment.