From cf687e58e5b4c07a3d14580d006dcc978c3d2233 Mon Sep 17 00:00:00 2001 From: David Glick Date: Wed, 12 Jun 2024 11:50:56 -0700 Subject: [PATCH] Set PIL.ImageFile.LOAD_TRUNCATED_IMAGES = True --- news/14.bugfix | 1 + plone/scale/scale.py | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 news/14.bugfix diff --git a/news/14.bugfix b/news/14.bugfix new file mode 100644 index 0000000..09ad50c --- /dev/null +++ b/news/14.bugfix @@ -0,0 +1 @@ +Set PIL.ImageFile.LOAD_TRUNCATED_IMAGES = True to try to load damaged images. @davisagli diff --git a/plone/scale/scale.py b/plone/scale/scale.py index c3f7624..e84e998 100644 --- a/plone/scale/scale.py +++ b/plone/scale/scale.py @@ -39,6 +39,9 @@ def none_as_int(the_int): # details. PIL.ImageFile.MAXBLOCK = 1000000 +# Try to load images even if they're truncated or have a failing CRC. +PIL.ImageFile.LOAD_TRUNCATED_IMAGES = True + MAX_PIXELS = 8192 * 8192