From c20990fca35fe82eec5fbe6fab998f47a08562ff Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 12 Apr 2025 04:41:38 -0400 Subject: [PATCH] Do not call `resize_image_to_height` on smaller images --- tubesync/sync/tasks.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tubesync/sync/tasks.py b/tubesync/sync/tasks.py index 3b02e029..e7f31581 100644 --- a/tubesync/sync/tasks.py +++ b/tubesync/sync/tasks.py @@ -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)