From 9344b067b1db54b641c36f651c4255c2857211f1 Mon Sep 17 00:00:00 2001 From: Thomas Albrecht Date: Mon, 20 Apr 2020 14:48:30 +0200 Subject: [PATCH] fix: OSError:broken data stream (#1430) --- CHANGELOG.md | 1 + cvat/apps/engine/media_extractors.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56206927..e297fc1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Auto annotation, TF annotation and Auto segmentation apps (https://github.com/opencv/cvat/pull/1409) +- Import works with truncated images now: "OSError:broken data stream" on corrupt images (https://github.com/opencv/cvat/pull/1430) ### Security - diff --git a/cvat/apps/engine/media_extractors.py b/cvat/apps/engine/media_extractors.py index c32d7abd..18d28f20 100644 --- a/cvat/apps/engine/media_extractors.py +++ b/cvat/apps/engine/media_extractors.py @@ -13,7 +13,11 @@ import av import av.datasets import numpy as np from pyunpack import Archive -from PIL import Image +from PIL import Image, ImageFile + +# fixes: "OSError:broken data stream" when executing line 72 while loading images downloaded from the web +# see: https://stackoverflow.com/questions/42462431/oserror-broken-data-stream-when-reading-image-file +ImageFile.LOAD_TRUNCATED_IMAGES = True from cvat.apps.engine.mime_types import mimetypes