metadata: fixed bug in setting shutter speed in output jpgs
(cherry picked from commit b6a1a15a76c2091f6f940ae7d16d45caa93dbb99)
This commit is contained in:
parent
77d1bc2cb1
commit
a73e74f9cc
@ -695,11 +695,12 @@ std::string FramesMetaData::apertureToString(double aperture)
|
||||
|
||||
std::string FramesMetaData::shutterToString(double shutter)
|
||||
{
|
||||
|
||||
char buffer[256];
|
||||
|
||||
if (shutter > 0.0 && shutter <= 0.5) {
|
||||
snprintf(buffer, sizeof(buffer), "1/%0.0f", 1.0 / shutter);
|
||||
} else if (int(shutter) == shutter) {
|
||||
snprintf(buffer, sizeof(buffer), "%d", int(shutter));
|
||||
} else {
|
||||
snprintf(buffer, sizeof(buffer), "%0.1f", shutter);
|
||||
}
|
||||
@ -755,6 +756,9 @@ void set_exif(Exiv2::ExifData &exif, const std::string &key, T val)
|
||||
try {
|
||||
exif[key] = val;
|
||||
} catch (std::exception &exc) {
|
||||
if (settings->verbose) {
|
||||
std::cout << "Exif -- error setting " << key << " to " << val << ": " << exc.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -768,7 +772,11 @@ void FramesData::fillBasicTags(Exiv2::ExifData &exif) const
|
||||
set_exif(exif, "Exif.Photo.ISOSpeedRatings", getISOSpeed());
|
||||
set_exif(exif, "Exif.Photo.FNumber", Exiv2::URationalValue(Exiv2::URational(round(getFNumber() * 10), 10)));
|
||||
auto s = shutterToString(getShutterSpeed());
|
||||
if (s.find('/') == std::string::npos) {
|
||||
auto p = s.find('.');
|
||||
if (p != std::string::npos) {
|
||||
assert(p == s.length()-2);
|
||||
s = s.substr(0, p) + s.substr(p+1) + "/10";
|
||||
} else if (s.find('/') == std::string::npos) {
|
||||
s += "/1";
|
||||
}
|
||||
set_exif(exif, "Exif.Photo.ExposureTime", s);
|
||||
|
Loading…
x
Reference in New Issue
Block a user