From 935b2493939eac1d795add6911138caffa89cc18 Mon Sep 17 00:00:00 2001
From: Yoann Schneider <yschneider@teklia.com>
Date: Wed, 13 Sep 2023 18:26:55 +0200
Subject: [PATCH] Allow resizing sub elements

---
 arkindex_worker/models.py | 13 +------------
 tests/test_element.py     |  2 +-
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/arkindex_worker/models.py b/arkindex_worker/models.py
index d79495a6..a65b4466 100644
--- a/arkindex_worker/models.py
+++ b/arkindex_worker/models.py
@@ -187,20 +187,9 @@ class Element(MagicDict):
         if max_width is None and max_height is None:
             resize = "full"
         else:
-            bounding_box = polygon_bounding_box(self.zone.polygon)
             original_size = {"w": self.zone.image.width, "h": self.zone.image.height}
-            # No resizing if the element is smaller than the image.
-            if (
-                bounding_box.width != original_size["w"]
-                or bounding_box.height != original_size["h"]
-            ):
-                resize = "full"
-                logger.warning(
-                    "Only full image size elements covered, "
-                    + "downloading full size image."
-                )
             # No resizing if the image is smaller than the wanted size.
-            elif (max_width is None or original_size["w"] <= max_width) and (
+            if (max_width is None or original_size["w"] <= max_width) and (
                 max_height is None or original_size["h"] <= max_height
             ):
                 resize = "full"
diff --git a/tests/test_element.py b/tests/test_element.py
index 734d5c81..0f301529 100644
--- a/tests/test_element.py
+++ b/tests/test_element.py
@@ -141,7 +141,7 @@ def test_open_image_resize_partial_element(mocker):
     assert elt.open_image(max_height=400, use_full_image=True) == "an image!"
     assert open_mock.call_count == 1
     assert open_mock.call_args == mocker.call(
-        "http://something/full/full/0/default.jpg",
+        "http://something/full/,400/0/default.jpg",
         rotation_angle=0,
         mirrored=False,
     )
-- 
GitLab