@@ -128,10 +128,13 @@ def generate(self, storage, original, size, miniature):
128128 format = image .format # Save format for the save() call later
129129 image .thumbnail ([w , h ], Image .ANTIALIAS )
130130 buf = BytesIO ()
131- if image .mode not in ("RGBA" , "RGB" , "L" ):
132- image = image .convert ("RGBA" )
133131 if format .lower () not in ("jpg" , "jpeg" , "png" ):
134132 format = "jpeg"
133+ if image .mode not in ("RGBA" , "RGB" , "L" ):
134+ if format == "png" :
135+ image = image .convert ("RGBA" )
136+ else :
137+ image = image .convert ("RGB" )
135138 image .save (buf , format , quality = 90 )
136139 raw_data = buf .getvalue ()
137140 buf .close ()
@@ -186,10 +189,13 @@ def generate(self, storage, original, size, miniature):
186189 image = image .resize ((dst_width , dst_height ), Image .ANTIALIAS )
187190
188191 buf = BytesIO ()
189- if image .mode not in ("RGBA" , "RGB" , "L" ):
190- image = image .convert ("RGBA" )
191192 if format .lower () not in ("jpg" , "jpeg" , "png" ):
192193 format = "jpeg"
194+ if image .mode not in ("RGBA" , "RGB" , "L" ):
195+ if format == "png" :
196+ image = image .convert ("RGBA" )
197+ else :
198+ image = image .convert ("RGB" )
193199 image .save (buf , format , quality = 90 )
194200 raw_data = buf .getvalue ()
195201 buf .close ()
0 commit comments