@@ -1723,6 +1723,8 @@ def has_thumbnail(self):
1723
1723
# that indexing (or other listeners) are notified
1724
1724
def save_thumbnail (self , filename , image ):
1725
1725
upload_path = get_unique_upload_path (filename )
1726
+ # force convertion to JPEG output file
1727
+ upload_path = f'{ os .path .splitext (upload_path )[0 ]} .jpg'
1726
1728
try :
1727
1729
# Check that the image is valid
1728
1730
if is_monochromatic_image (None , image ):
@@ -1743,14 +1745,11 @@ def save_thumbnail(self, filename, image):
1743
1745
# Optimize the Thumbnail size and resolution
1744
1746
_default_thumb_size = settings .THUMBNAIL_SIZE
1745
1747
im = Image .open (storage_manager .open (actual_name ))
1746
- im .thumbnail (
1747
- (_default_thumb_size ['width' ], _default_thumb_size ['height' ]),
1748
- resample = Image .ANTIALIAS )
1749
- cover = ImageOps .fit (im , (_default_thumb_size ['width' ], _default_thumb_size ['height' ]))
1748
+ cover = ImageOps .fit (im , (_default_thumb_size ['width' ], _default_thumb_size ['height' ])).convert ("RGB" )
1750
1749
1751
1750
# Saving the thumb into a temporary directory on file system
1752
1751
tmp_location = os .path .abspath (f"{ settings .MEDIA_ROOT } /{ upload_path } " )
1753
- cover .save (tmp_location , format = 'PNG' )
1752
+ cover .save (tmp_location , quality = "high" )
1754
1753
1755
1754
with open (tmp_location , 'rb+' ) as img :
1756
1755
# Saving the img via storage manager
0 commit comments