From a486abb159b5c0d25d28cc0de40ea3583796db0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 16 Jan 2020 22:54:12 +0100 Subject: [PATCH] Added workaround for broken GPS IFD entries produced by NOKIA phones Closes #260 --- src/common/tifffile.h | 1 + src/data/exifparser.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/tifffile.h b/src/common/tifffile.h index 9ec461b0..c2634ea3 100644 --- a/src/common/tifffile.h +++ b/src/common/tifffile.h @@ -9,6 +9,7 @@ #define TIFF_SHORT 3 #define TIFF_LONG 4 #define TIFF_RATIONAL 5 +#define TIFF_SRATIONAL 10 #define TIFF_DOUBLE 12 class TIFFFile diff --git a/src/data/exifparser.cpp b/src/data/exifparser.cpp index 5bb85eb6..9c257ff4 100644 --- a/src/data/exifparser.cpp +++ b/src/data/exifparser.cpp @@ -82,7 +82,10 @@ double EXIFParser::altitude(TIFFFile &file, const IFDEntry &alt, double EXIFParser::coordinate(TIFFFile &file, const IFDEntry &ll) const { - if (!(ll.type == TIFF_RATIONAL && ll.count == 3)) + // Some broken image creators like NOKIA phones use a wrong (SRATIONAL) + // data type + if (!((ll.type == TIFF_RATIONAL || ll.type == TIFF_SRATIONAL) + && ll.count == 3)) return NAN; if (!file.seek(ll.offset))