Skip to content

Commit

Permalink
Disable implicit thumbnail upscaling (#930)
Browse files Browse the repository at this point in the history
  • Loading branch information
dairiki committed Dec 13, 2021
1 parent 61763fe commit 79904cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
10 changes: 0 additions & 10 deletions lektor/imagetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,16 +593,6 @@ def make_image_thumbnail(

would_upscale = computed_width > source_width or computed_height > source_height

# this part needs to be removed once backward-compatibility period passes
if would_upscale and upscale is None:
warnings.warn(
"Your image is being scaled up since the requested thumbnail "
"size is larger than the source. This default will change "
"in the future. If you want to preserve the current behaviour, "
"use `upscale=True`."
)
upscale = True

if would_upscale and not upscale:
return Thumbnail(source_url_path, source_width, source_height)

Expand Down
11 changes: 5 additions & 6 deletions tests/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,11 @@ def test_scale(
assert rv.url_path != source_url_path
assert len(ctx.sub_artifacts) == 1

def test_implicit_upscale(self, ctx, test_jpg, source_url_path):
with pytest.warns(UserWarning, match=r"image is being scaled up"):
rv = make_image_thumbnail(ctx, test_jpg, source_url_path, 512)
assert (rv.width, rv.height) == (512, 683)
assert rv.url_path == "test@512.jpg"
assert len(ctx.sub_artifacts) == 1
def test_no_implicit_upscale(self, ctx, test_jpg, source_url_path):
rv = make_image_thumbnail(ctx, test_jpg, source_url_path, 512)
assert (rv.width, rv.height) == (384, 512)
assert rv.url_path == "test.jpg"
assert len(ctx.sub_artifacts) == 0

@pytest.mark.parametrize("mode", iter(ThumbnailMode))
def test_upscale_false(self, ctx, test_jpg, source_url_path, mode):
Expand Down

0 comments on commit 79904cb

Please sign in to comment.