Do not call resize_image_to_height on smaller images

This commit is contained in:
tcely 2025-04-12 04:41:38 -04:00 committed by GitHub
parent 3207f85e08
commit c20990fca3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -501,9 +501,10 @@ def download_media_thumbnail(media_id, url):
width = getattr(settings, 'MEDIA_THUMBNAIL_WIDTH', 430)
height = getattr(settings, 'MEDIA_THUMBNAIL_HEIGHT', 240)
i = get_remote_image(url)
log.info(f'Resizing {i.width}x{i.height} thumbnail to '
f'{width}x{height}: {url}')
i = resize_image_to_height(i, width, height)
if (i.width > width) and (i.height > height):
log.info(f'Resizing {i.width}x{i.height} thumbnail to '
f'{width}x{height}: {url}')
i = resize_image_to_height(i, width, height)
image_file = BytesIO()
i.save(image_file, 'JPEG', quality=85, optimize=True, progressive=True)
image_file.seek(0)