Dive pictures: If EXIF data couldn't be parsed, use creation date

This is a preparation for supporting videos. Some video formats may
not possess such meta data, or we may not yet be able to parse them.
In such a case, use the file creation date.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Berthold Stoeger 2018-03-13 09:44:48 +01:00 committed by Dirk Hohndel
parent d9b502f0c7
commit c896938f7a

View file

@ -402,8 +402,12 @@ static int parseExif(const QString &filename, easyexif::EXIFInfo &exif)
extern "C" timestamp_t picture_get_timestamp(const char *filename)
{
easyexif::EXIFInfo exif;
if (parseExif(localFilePath(QString(filename)), exif) != PARSE_EXIF_SUCCESS)
return 0;
if (parseExif(localFilePath(QString(filename)), exif) != PARSE_EXIF_SUCCESS) {
// If we couldn't parse EXIF data, use file creation date.
// TODO: QFileInfo::created is deprecated in newer Qt versions.
QDateTime created = QFileInfo(QString(filename)).created();
return created.toSecsSinceEpoch();
}
return exif.epoch();
}