diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index d8cec7604..da0c136fc 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "imagedata.h" #include "imagesource.h" @@ -311,6 +313,8 @@ FramesData::FramesData(const Glib::ustring &fname) : } else if (find_exif_tag("Exif.Photo.DateTimeDigitized")) { datetime_taken = pos->print(&exif); + } else if (find_exif_tag("Exif.Image.DateTime")) { + datetime_taken = validateUft8(pos->print(&exif)); } if (sscanf(datetime_taken.c_str(), "%d:%d:%d %d:%d:%d", &time.tm_year, &time.tm_mon, &time.tm_mday, &time.tm_hour, &time.tm_min, &time.tm_sec) == 6) { time.tm_year -= 1900; @@ -334,6 +338,42 @@ FramesData::FramesData(const Glib::ustring &fname) : } } + // try getting some metadata from ImageDescription + if (!make.compare(0, 5, "KODAK") && !getISOSpeed() && !getFNumber() && !getFocalLen() && !getShutterSpeed() && + find_exif_tag("Exif.Image.ImageDescription")) { + std::string s = pos->toString(); + std::string line; + std::smatch m; + const auto d = + [&m]() -> double { + std::string s = m[1]; + return atof(s.c_str()); + }; + while (true) { + auto p = s.find('\r'); + if (p == std::string::npos) { + break; + } + auto line = s.substr(0, p); + s = s.substr(p+1); + + if (std::regex_match(line, m, std::regex("ISO: +([0-9]+) *"))) { + iso_speed = d(); + } else if (std::regex_match(line, m, std::regex("Aperture: +F([0-9.]+) *"))) { + aperture = d(); + } else if (std::regex_match(line, m, std::regex("Shutter: +([0-9.]+) *"))) { + shutter = d(); + if (shutter) { + shutter = 1.0/shutter; + } + } else if (std::regex_match(line, m, std::regex("Lens \\(mm\\): +([0-9.]+) *"))) { + focal_len = d(); + } else if (std::regex_match(line, m, std::regex("Exp Comp: +([0-9.]+) *"))) { + expcomp = d(); + } + } + } + // ----------------------- // Special file type detection (HDR, PixelShift) // ------------------------