From 8944f614ee13fed5532a0eb81825813696b85f58 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Fri, 19 May 2017 11:05:40 +0200 Subject: [PATCH] reduce logging level --- CHANGES.rst | 3 +++ plone/namedfile/utils/__init__.py | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 137cdad5..b52c670d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -23,6 +23,9 @@ Bug fixes: - Fix bug on Image rotation if ImageIFD.XResolution or ImageIFD.YResolution are not set. [loechel] +- Fix: Do not log failing PIL image regognition as error, but as warning. + [jensens] + 4.2.0 (2017-03-26) ------------------ diff --git a/plone/namedfile/utils/__init__.py b/plone/namedfile/utils/__init__.py index 2ec9a8ce..7ce3350f 100644 --- a/plone/namedfile/utils/__init__.py +++ b/plone/namedfile/utils/__init__.py @@ -141,11 +141,14 @@ def getImageInfo(data): img = PIL.Image.open(StringIO(data)) width, height = img.size content_type = img.format - except Exception as e: + except Exception: # TODO: determ wich error really happens # Should happen if data is to short --> first_bytes - log.error(e) - # return 'image/jpeg', -1, -1 + # happens also if data is an svg or another special format. + log.warn( + 'PIL can not recognize the image. ' + 'Image is probably broken or of a non-supported format.' + ) log.debug('Image Info (Type: %s, Width: %s, Height: %s)', content_type, width, height)