Skip to content

Commit f2b1dd2

Browse files
committed
Fixed #50 -- Cast size to int tupel
1 parent 8324940 commit f2b1dd2

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

stdimage/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,17 @@ def render_variation(cls, file_name, variation, replace=False,
9191
resample=resample
9292
)
9393

94+
size = variation['width'], variation['height']
95+
size = tuple(int(i) for i in size)
9496
if variation['crop']:
9597
img = ImageOps.fit(
9698
img,
97-
(variation['width'], variation['height']),
99+
size,
98100
method=resample
99101
)
100102
else:
101103
img.thumbnail(
102-
(variation['width'], variation['height']),
104+
size,
103105
resample=resample
104106
)
105107

tests/test_commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import os
22
import time
33

4+
import pytest
45
from django.core.management import call_command
56

67
from tests.models import ManualVariationsModel, ThumbnailModel
78

89

10+
@pytest.mark.django_db
911
class TestRenderVariations(object):
1012
def test_no_options(self, image_upload_file):
1113
obj = ManualVariationsModel.customer_manager.create(

tests/test_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import os
22

3+
import pytest
34
from PIL import Image
45

56
from stdimage.utils import render_variations
67
from tests.models import ManualVariationsModel
78
from tests.test_models import IMG_DIR
89

910

11+
@pytest.mark.django_db
1012
class TestRenderVariations(object):
1113
def test_render_variations(self, image_upload_file):
1214
instance = ManualVariationsModel.customer_manager.create(

0 commit comments

Comments
 (0)