From b76fd26c0f908d60923c9e1f769a3b033b98c592 Mon Sep 17 00:00:00 2001 From: "d.bianchi" Date: Fri, 10 Mar 2023 15:44:30 +0100 Subject: [PATCH] Create thumbnail from files saved with wrong extension --- sorl/thumbnail/engines/pil_engine.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sorl/thumbnail/engines/pil_engine.py b/sorl/thumbnail/engines/pil_engine.py index 5371be42c..e67572976 100644 --- a/sorl/thumbnail/engines/pil_engine.py +++ b/sorl/thumbnail/engines/pil_engine.py @@ -151,6 +151,8 @@ def _colorspace(self, image, colorspace, format): # Pillow JPEG doesn't allow RGBA anymore. It was converted to RGB before. if image.mode == 'RGBA' and format != 'JPEG': return image # RGBA is just RGB + Alpha + if image.mode == 'RGBA' and format == 'JPEG' and image.format != 'JPEG': + return image.convert('RGB') if image.mode == 'LA' or ( image.mode == 'P' and 'transparency' in image.info and format != 'JPEG' ):