mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 06:17:07 +00:00
Handle exception from pillow (#16190)
This commit is contained in:
parent
d166f2da80
commit
499bb3f4a2
@ -64,7 +64,10 @@ def _resize_image(image, opts):
|
|||||||
quality = opts.quality or DEFAULT_QUALITY
|
quality = opts.quality or DEFAULT_QUALITY
|
||||||
new_width = opts.max_width
|
new_width = opts.max_width
|
||||||
|
|
||||||
|
try:
|
||||||
img = Image.open(io.BytesIO(image))
|
img = Image.open(io.BytesIO(image))
|
||||||
|
except IOError:
|
||||||
|
return image
|
||||||
imgfmt = str(img.format)
|
imgfmt = str(img.format)
|
||||||
if imgfmt not in ('PNG', 'JPEG'):
|
if imgfmt not in ('PNG', 'JPEG'):
|
||||||
_LOGGER.debug("Image is of unsupported type: %s", imgfmt)
|
_LOGGER.debug("Image is of unsupported type: %s", imgfmt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user