Skip to content

Commit

Permalink
exif: use Exif.Photo.LensModel as default.
Browse files Browse the repository at this point in the history
If no other maker tags have been used or have meaningful values we default
to a safe Exif.Photo.LensModel if it exists.

Better fix for darktable-org#4951 and more generic should could solve similar issues
for other maker/model.
  • Loading branch information
TurboGit committed May 10, 2020
1 parent 2782670 commit 8e9d45b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/common/exif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -953,15 +953,6 @@ static bool _exif_decode_exif_data(dt_image_t *img, Exiv2::ExifData &exifData)
|| FIND_EXIF_TAG("Exif.Canon.0x0095"))
{
dt_strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);

// if exif_lens is only numbers and we have a Exif.Photo.LensModel defined
// use it.
std::string lens(img->exif_lens);
if(std::string::npos == lens.find_first_not_of(" 1234567890"))
if(FIND_EXIF_TAG("Exif.Photo.LensModel"))
{
dt_strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);
}
}
else if(EXIV2_MAKE_VERSION(0,25,0) <= Exiv2::versionNumber() && FIND_EXIF_TAG("Exif.PentaxDng.LensType"))
{
Expand Down Expand Up @@ -1000,7 +991,13 @@ static bool _exif_decode_exif_data(dt_image_t *img, Exiv2::ExifData &exifData)
{
dt_strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);
}
else if(FIND_EXIF_TAG("Exif.Photo.LensModel"))

// finaly the lens has only numbers and parentheses, let's try to use
// Exif.Photo.LensModel if defined.

std::string lens(img->exif_lens);
if(std::string::npos == lens.find_first_not_of(" (1234567890)")
&& FIND_EXIF_TAG("Exif.Photo.LensModel"))
{
dt_strlcpy_to_utf8(img->exif_lens, sizeof(img->exif_lens), pos, exifData);
}
Expand Down

0 comments on commit 8e9d45b

Please sign in to comment.