Skip to content

Commit b95584d

Browse files
committed
Use jpeg instead of webp for processed image. Fix #44
1 parent 55fb5e2 commit b95584d

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

mosquito_alert/images/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class Photo(FlagModeratedModel, TimeStampedModel):
4141
# Check PIL.ImageOps.exif_transpose()
4242
image = ProcessedImageField(
4343
upload_to=image_upload_to,
44-
processors=[ResizeToFit(height=720, upscale=False)],
45-
format="WEBP",
46-
options={"quality": 85},
44+
processors=[ResizeToFit(height=1080, upscale=False)],
45+
format="JPEG",
46+
options={"quality": 95},
4747
)
4848
# TODO: license + attributions
4949

mosquito_alert/images/tests/test_models.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,28 @@ def test_image_filaname_is_replaced_to_uuid_from_id(self):
4242
filename, _ = os.path.splitext(os.path.basename(p.image.name))
4343
assert filename == str(new_uuid)
4444

45-
def test_image_is_converted_to_webp(self):
46-
assert self.model._meta.get_field("image")._original_spec.format == "WEBP"
45+
def test_image_is_converted_to_jpeg(self):
46+
assert self.model._meta.get_field("image")._original_spec.format == "JPEG"
4747

4848
# Check filename extension
4949
p = self.factory_cls(image__filename="example.png", image__format="PNG")
5050
_, ext = os.path.splitext(os.path.basename(p.image.name))
51-
assert ext == ".webp"
51+
assert ext == ".jpg"
5252

53-
# Check format is WEBP
54-
assert Image.open(p.image).format == "WEBP"
53+
# Check format is JPEG
54+
assert Image.open(p.image).format == "JPEG"
5555

56-
def test_image_is_resized_to_720p(self):
57-
p = self.factory_cls(image__width=2049, image__height=1080)
56+
def test_image_is_resized_to_1080p(self):
57+
p = self.factory_cls(image__width=3840, image__height=1620)
5858

59-
target_sizing_factor = 1080 / 720
59+
target_sizing_factor = 1620 / 1080
6060
# It should perform a downsizing for factor 1.5
6161

6262
# Metatada in the field
63-
assert p.image.width == 2049 / target_sizing_factor
64-
assert p.image.height == 720
63+
assert p.image.width == 3840 / target_sizing_factor
64+
assert p.image.height == 1080
6565

66-
def test_image_is_not_resized_if_smaller_than_720p(self):
66+
def test_image_is_not_resized_if_smaller_than_1080p(self):
6767
p = self.factory_cls(image__width=1080, image__height=600)
6868

6969
assert p.image.width == 1080

0 commit comments

Comments
 (0)