Skip to content

Commit

Permalink
Fix multiple jpeg file conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsmkn authored and codingjoe committed May 31, 2021
1 parent 3a91926 commit 5c72f04
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions stdimage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 5c72f04

Please sign in to comment.