Skip to content

Commit 5c72f04

Browse files
jmsmkncodingjoe
authored andcommitted
Fix multiple jpeg file conversion
1 parent 3a91926 commit 5c72f04

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

stdimage/models.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,13 @@ def process_variation(cls, variation, image):
304304

305305
resample = variation["resample"]
306306

307-
if variation["width"] is None:
308-
variation["width"] = image.size[0]
309-
310-
if variation["height"] is None:
311-
variation["height"] = image.size[1]
307+
width = image.size[0] if variation["width"] is None else variation["width"]
308+
height = image.size[1] if variation["height"] is None else variation["height"]
312309

313310
factor = 1
314311
while (
315-
image.size[0] / factor > 2 * variation["width"]
316-
and image.size[1] * 2 / factor > 2 * variation["height"]
312+
image.size[0] / factor > 2 * width
313+
and image.size[1] * 2 / factor > 2 * height
317314
):
318315
factor *= 2
319316
if factor > 1:
@@ -322,7 +319,7 @@ def process_variation(cls, variation, image):
322319
resample=resample,
323320
)
324321

325-
size = variation["width"], variation["height"]
322+
size = width, height
326323
size = tuple(int(i) if i is not None else i for i in size)
327324

328325
# http://stackoverflow.com/a/21669827

0 commit comments

Comments
 (0)