Skip to content

Commit ceca21d

Browse files
authored
Merge pull request #787 from bal-a/bal/bugfix-thumbnail
bugfix/gracefully-handle-large-thumbnails
2 parents f33bd35 + 6b2a36d commit ceca21d

30 files changed

+104
-32
lines changed

mapillary_tools/authenticate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import typing as T
88

99
import jsonschema
10-
1110
import requests
1211

1312
from . import api_v4, config, constants, exceptions, http

mapillary_tools/blackvue_parser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import dataclasses
4-
54
import json
65
import logging
76
import re

mapillary_tools/camm/camm_builder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
mp4_sample_parser as sample_parser,
1010
simple_mp4_builder as builder,
1111
)
12-
1312
from . import camm_parser
1413

1514

mapillary_tools/commands/process_and_upload.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import inspect
22

33
from ..authenticate import fetch_user_items
4-
54
from .process import Command as ProcessCommand
65
from .upload import Command as UploadCommand
76

mapillary_tools/commands/video_process_and_upload.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import inspect
22

33
from ..authenticate import fetch_user_items
4-
54
from .upload import Command as UploadCommand
65
from .video_process import Command as VideoProcessCommand
76

mapillary_tools/exif_write.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,18 @@ def _safe_dump(self) -> bytes:
214214
else:
215215
del self._ef[ifd][tag]
216216
# retry later
217+
elif "thumbnail is too large" in message.lower():
218+
# Handle oversized thumbnails (max 64kB per EXIF spec)
219+
if thumbnail_removed:
220+
raise exc
221+
LOG.debug(
222+
"Thumbnail too large (max 64kB) -- removing thumbnail and 1st: %s",
223+
exc,
224+
)
225+
del self._ef["thumbnail"]
226+
del self._ef["1st"]
227+
thumbnail_removed = True
228+
# retry later
217229
else:
218230
raise exc
219231
except Exception as exc:

mapillary_tools/http.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import logging
4-
54
import ssl
65
import sys
76
import typing as T

mapillary_tools/serializer/gpx.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import gpxpy.gpx
1313

1414
from .. import geo, types
15-
1615
from ..telemetry import CAMMGPSPoint, GPSPoint
1716
from ..types import (
1817
BaseSerializer,

mapillary_tools/uploader.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,10 @@ def dump_image_bytes(cls, metadata: types.ImageMetadata) -> bytes:
797797
raise ExifError(
798798
f"Failed to dump EXIF bytes: {ex}", metadata.filename
799799
) from ex
800+
except ValueError as ex:
801+
raise ExifError(
802+
f"Failed to dump EXIF bytes: {ex}", metadata.filename
803+
) from ex
800804

801805
# Thread-safe
802806
def _get_cached_file_handle(self, key: str) -> str | None:

mapillary_tools/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import concurrent.futures
4-
54
import hashlib
65
import logging
76
import os

0 commit comments

Comments
 (0)