Repository: lektor/lektor

Issue:
Disable deprecated implicit thumbnail upscaling?
Implicit thumbnail upscaling, as well as the `crop` argument to [`Image.thumbnail`](https://github.com/lektor/lektor/blob/f135d73a11ac557bff4f1068958e71b6b526ee63/lektor/db.py#L818) have been [deprecated](https://github.com/lektor/lektor/blob/f135d73a11ac557bff4f1068958e71b6b526ee63/lektor/imagetools.py#L598) since release 3.2.0.

This issue is here to make sure we don't forget to disable those features when the time is right.

(This issue should probably be attached to the [4.0 Milestone](https://github.com/lektor/lektor/milestone/5), but I don't think that I have sufficient privileges to do so.)

Refs: #551, #885

Comments:

Patch:
diff --git a/lektor/db.py b/lektor/db.py
index 6cfcea9..bae4b54 100644
--- a/lektor/db.py
+++ b/lektor/db.py
@@ -6,7 +6,6 @@ import hashlib
 import operator
 import os
 import posixpath
-import warnings
 from collections import OrderedDict
 from datetime import timedelta
 from itertools import islice
@@ -832,21 +831,9 @@ class Image(Attachment):
             return rv
         return Undefined("The format of the image could not be determined.")
 
-    def thumbnail(
-        self, width=None, height=None, crop=None, mode=None, upscale=None, quality=None
-    ):
+    def thumbnail(self, width=None, height=None, mode=None, upscale=None, quality=None):
         """Utility to create thumbnails."""
 
-        # `crop` exists to preserve backward-compatibility, and will be removed.
-        if crop is not None and mode is not None:
-            raise ValueError("Arguments `crop` and `mode` are mutually exclusive.")
-
-        if crop is not None:
-            warnings.warn(
-                'The `crop` argument is deprecated. Use `mode="crop"` instead.'
-            )
-            mode = "crop"
-
         if mode is None:
             mode = ThumbnailMode.DEFAULT
         else:
diff --git a/lektor/imagetools.py b/lektor/imagetools.py
index fcfcc1a..0418aa5 100644
--- a/lektor/imagetools.py
+++ b/lektor/imagetools.py
@@ -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)
 


Test patch:
diff --git a/tests/test_images.py b/tests/test_images.py
index 8609864..ae13a53 100644
--- a/tests/test_images.py
+++ b/tests/test_images.py
@@ -329,12 +329,11 @@ class Test_make_image_thumbnail:
         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):