tnc-ca-geo / animl-ingest

Lambda function for processing camera trap images
Other
0 stars 1 forks source link

Reject images w/o DateTimeOriginal #58

Closed nathanielrindlaub closed 1 year ago

nathanielrindlaub commented 1 year ago

Very rarely (but sometimes, e.g. if the image has been modified or edited in some other program) images don't have DateTimeOriginal tags in their EXIF data, and when ingest-image encounters that it throws the following error:

ERROR   Invoke Error    
{
    "errorType": "TimestampParseError",
    "errorMessage": "Failed to parse token \":\" at position [0] in timestamp \"undefined\" with format \"%Y:%m:%d %H:%M:%S\": String literal \":\" not matched.",
    "reason": "String literal \":\" not matched.",
    "format": "%Y:%m:%d %H:%M:%S",
    "timestamp": "undefined",
    "token": {
        "string": ":"
    },
    "index": 0,
    "message": "Failed to parse token \":\" at position [0] in timestamp \"undefined\" with format \"%Y:%m:%d %H:%M:%S\": String literal \":\" not matched.",
    "stack": [
        "TimestampParseError: Failed to parse token \":\" at position [0] in timestamp \"undefined\" with format \"%Y:%m:%d %H:%M:%S\": String literal \":\" not matched.",
        "    at TimestampParser.parseStringToken (/var/task/node_modules/strtime/dist/strtime.js:1213:23)",
        "    at TimestampParser.parse (/var/task/node_modules/strtime/dist/strtime.js:1186:22)",
        "    at strptime (/var/task/node_modules/strtime/dist/strtime.js:106:27)",
        "    at Task.convert_datetime_to_ISO (file:///var/task/task.js:273:31)",
        "    at Task.enrich_meta_data (file:///var/task/task.js:285:36)",
        "    at Task.process_image (file:///var/task/task.js:119:25)",
        "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
        "    at async Task.control (file:///var/task/task.js:78:21)",
        "    at async Runtime.handler (file:///var/task/task.js:343:5)"
    ]
}

I am open to ideas on alternative ways to handle this situation, but perhaps a first step is rejecting them, writing the error to the image errors collection (see #42, and moving them to the dead-letter bucket).