Skip to content

Commit 18f1e53

Browse files
committed
treat MPO files as plain JPEGs
1 parent 3f054bd commit 18f1e53

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/bma_client_lib/pillow_resize_and_crop.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
from fractions import Fraction
88
from math import floor
99

10-
from PIL import Image, ImageFile, ImageSequence
10+
from PIL import Image, ImageFile, ImageSequence, JpegImagePlugin
1111

1212
logger = logging.getLogger("bma_client")
1313

14+
# some cameras save JPEGs as MPO with embedded thumbnails,
15+
# can also be used for 3d images, handle MPO files as plain JPEGs for now
16+
# https://github.com/python-pillow/Pillow/issues/1138
17+
# https://github.com/python-pillow/Pillow/issues/4603
18+
JpegImagePlugin._getmp = lambda _x: None # type: ignore[assignment] # noqa: SLF001
19+
1420

1521
def transform_image(
1622
original_img: Image.Image, crop_w: int, crop_h: int, center_point: tuple[float, float] = (0.5, 0.5)

0 commit comments

Comments
 (0)