From 5c72f048b462c11df13a05a8199ed30ca3780529 Mon Sep 17 00:00:00 2001 From: James Meakin <12661555+jmsmkn@users.noreply.github.com> Date: Thu, 13 May 2021 10:49:35 +0200 Subject: [PATCH] Fix multiple jpeg file conversion --- stdimage/models.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/stdimage/models.py b/stdimage/models.py index 2722ee8..0eb6943 100644 --- a/stdimage/models.py +++ b/stdimage/models.py @@ -304,16 +304,13 @@ def process_variation(cls, variation, image): resample = variation["resample"] - if variation["width"] is None: - variation["width"] = image.size[0] - - if variation["height"] is None: - variation["height"] = image.size[1] + width = image.size[0] if variation["width"] is None else variation["width"] + height = image.size[1] if variation["height"] is None else variation["height"] factor = 1 while ( - image.size[0] / factor > 2 * variation["width"] - and image.size[1] * 2 / factor > 2 * variation["height"] + image.size[0] / factor > 2 * width + and image.size[1] * 2 / factor > 2 * height ): factor *= 2 if factor > 1: @@ -322,7 +319,7 @@ def process_variation(cls, variation, image): resample=resample, ) - size = variation["width"], variation["height"] + size = width, height size = tuple(int(i) if i is not None else i for i in size) # http://stackoverflow.com/a/21669827