Thumbnails for images and videos #87
@ -126,14 +126,14 @@ class UtilsTest(TestCase):
|
||||
def test_make_thumbnails(self, mock_resize_image):
|
||||
self.assertEqual(
|
||||
{
|
||||
'1080p': {'path': 'thumbnails/fo/foobar_1920x1080.png', 'size': (1920, 1080)},
|
||||
'360p': {'path': 'thumbnails/fo/foobar_640x360.png', 'size': (640, 360)},
|
||||
'1080p': {'path': 'thumbnails/fo/foobar_1920x1080.png', 'size': [1920, 1080]},
|
||||
'360p': {'path': 'thumbnails/fo/foobar_640x360.png', 'size': [640, 360]},
|
||||
},
|
||||
make_thumbnails(TEST_FILES_DIR / 'test_preview_image_0001.png', 'foobar'),
|
||||
)
|
||||
|
||||
self.assertEqual(len(mock_resize_image.mock_calls), 2)
|
||||
for expected_size in ((1920, 1080), (640, 360)):
|
||||
for expected_size in ([1920, 1080], [640, 360]):
|
||||
with self.subTest(expected_size=expected_size):
|
||||
mock_resize_image.assert_any_call(
|
||||
ANY,
|
||||
|
@ -237,9 +237,9 @@ def make_thumbnails(
|
||||
thumbnails = {}
|
||||
abs_path = os.path.join(settings.MEDIA_ROOT, source_path)
|
||||
image = Image.open(abs_path)
|
||||
for size_key, (w, h) in THUMBNAIL_SIZES.items():
|
||||
for size_key, size in THUMBNAIL_SIZES.items():
|
||||
w, h = size
|
||||
output_path = get_thumbnail_upload_to(file_hash, width=w, height=h)
|
||||
size = (w, h)
|
||||
with tempfile.TemporaryFile() as f:
|
||||
logger.info('Resizing %s to %s (%s)', abs_path, size, output_format)
|
||||
resize_image(
|
||||
|
Loading…
Reference in New Issue
Block a user