Skip to content

Reject image capture times before 1970, rather than crash on them - #911

Merged
caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:reject-pre-1970-capture-times
Oct 24, 2026
Merged

caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:reject-pre-1970-capture-times

Conversation

@caglarpir

Copy link
Copy Markdown
Contributor

Stacked on #910; review the last commit.

Cameras without a clock write placeholder dates: some FLIR thermal
cameras 0001:01:01 00:00:00, which #879 rejects as having no Unix time,
and others a date in 1904 or 1969:12:31 19:00:00 (Unix time 0 in a time
zone west of UTC). With a time zone offset, as when OffsetTimeOriginal
is +01:00, 0001:01:01 00:00:00 does have a Unix time, before year 1 in
UTC: the image passed, and writing its capture time to the description
crashed the whole run with "ValueError: year 0 is out of range". The
dates in 1904 and 1969 were taken as capture times: geotagged from a
GPX, such an image was reported as decades outside the track.

The EXIF, XMP and ExifTool readers now pass over a capture time before
1970, in the GPS date and in each EXIF date tag, so that the next date
tag is read: DateTimeOriginal, then CreateDate, then ModifyDate. An
image whose date tags all hold such dates has no capture time, and is
reported as a geotagging error, "Unable to extract timestamp from the
image". A capture time that cannot be written as a date no longer
crashes the run either: it fails the image's validation.

Checked process on 17,090 sample images from many camera models, with
the default sources and with exiftool_runtime: only three change. A
phone that writes a GPS date in 1961 beside the right DateTimeOriginal
is now dated by the latter, 47 years later. The two FLIR images dated
0001:01:01 are still reported as having no capture time, without the
date in the message. Given an OffsetTimeOriginal of +01:00, one of them
is reported the same way, where the run crashed.

Unit and integration tests, doctests, mypy --python-version 3.9, ruff check, ruff format --check and usort diff are clean.

@meta-cla meta-cla Bot added the cla signed label Oct 24, 2026
@caglarpir
caglarpir force-pushed the reject-pre-1970-capture-times branch from bbeba84 to d1b926a Compare October 24, 2026 12:55
Cameras without a clock write placeholder dates: some FLIR thermal
cameras 0001:01:01 00:00:00, which mapillary#879 rejects as having no Unix time,
and others a date in 1904 or 1969:12:31 19:00:00 (Unix time 0 in a time
zone west of UTC). With a time zone offset, as when OffsetTimeOriginal
is +01:00, 0001:01:01 00:00:00 does have a Unix time, before year 1 in
UTC: the image passed, and writing its capture time to the description
crashed the whole run with "ValueError: year 0 is out of range". The
dates in 1904 and 1969 were taken as capture times: geotagged from a
GPX, such an image was reported as decades outside the track.

The EXIF, XMP and ExifTool readers now pass over a capture time before
1970, in the GPS date and in each EXIF date tag, so that the next date
tag is read: DateTimeOriginal, then CreateDate, then ModifyDate. An
image whose date tags all hold such dates has no capture time, and is
reported as a geotagging error, "Unable to extract timestamp from the
image". A capture time that cannot be written as a date no longer
crashes the run either: it fails the image's validation.

Checked process on 17,090 sample images from many camera models, with
the default sources and with exiftool_runtime: only three change. A
phone that writes a GPS date in 1961 beside the right DateTimeOriginal
is now dated by the latter, 47 years later. The two FLIR images dated
0001:01:01 are still reported as having no capture time, without the
date in the message. Given an OffsetTimeOriginal of +01:00, one of them
is reported the same way, where the run crashed.
@caglarpir
caglarpir force-pushed the reject-pre-1970-capture-times branch from d1b926a to 0d2af34 Compare October 24, 2026 13:24
@caglarpir
caglarpir merged commit 116998c into mapillary:main Oct 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant