Skip to content
Snippets Groups Projects

Allow resizing sub elements

Merged Yoann Schneider requested to merge allow-resizing-subelements into master
1 file
+ 0
3
Compare changes
  • Side-by-side
  • Inline
+ 1
15
@@ -10,8 +10,6 @@ from typing import Generator, List, Optional
from PIL import Image
from requests import HTTPError
from arkindex_worker import logger
class MagicDict(dict):
"""
@@ -172,7 +170,6 @@ class Element(MagicDict):
from arkindex_worker.image import (
download_tiles,
open_image,
polygon_bounding_box,
)
if not self.get("zone"):
@@ -187,20 +184,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"
Loading