valetudo-map-parser 0.1.9b26__py3-none-any.whl → 0.1.9b27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- valetudo_map_parser/config/auto_crop.py +12 -1
- valetudo_map_parser/config/utils.py +8 -7
- valetudo_map_parser/hypfer_handler.py +1 -0
- valetudo_map_parser/rand25_handler.py +4 -0
- {valetudo_map_parser-0.1.9b26.dist-info → valetudo_map_parser-0.1.9b27.dist-info}/METADATA +1 -1
- {valetudo_map_parser-0.1.9b26.dist-info → valetudo_map_parser-0.1.9b27.dist-info}/RECORD +9 -9
- {valetudo_map_parser-0.1.9b26.dist-info → valetudo_map_parser-0.1.9b27.dist-info}/LICENSE +0 -0
- {valetudo_map_parser-0.1.9b26.dist-info → valetudo_map_parser-0.1.9b27.dist-info}/NOTICE.txt +0 -0
- {valetudo_map_parser-0.1.9b26.dist-info → valetudo_map_parser-0.1.9b27.dist-info}/WHEEL +0 -0
@@ -29,6 +29,14 @@ class AutoCrop:
|
|
29
29
|
self.imh = image_handler
|
30
30
|
self.file_name = self.imh.file_name
|
31
31
|
|
32
|
+
def validate_crop_dimensions(self, shared):
|
33
|
+
"""Ensure width and height are valid before processing cropping."""
|
34
|
+
if shared.image_ref_width <= 0 or shared.image_ref_height <= 0:
|
35
|
+
_LOGGER.warning("Auto-crop failed: Invalid dimensions (width=%s, height=%s). Using original image.",
|
36
|
+
shared.image_ref_width, shared.image_ref_height)
|
37
|
+
return False
|
38
|
+
return True
|
39
|
+
|
32
40
|
def check_trim(
|
33
41
|
self, trimmed_height, trimmed_width, margin_size, image_array, file_name, rotate
|
34
42
|
):
|
@@ -201,7 +209,10 @@ class AutoCrop:
|
|
201
209
|
Automatically crops and trims a numpy array and returns the processed image.
|
202
210
|
"""
|
203
211
|
try:
|
204
|
-
|
212
|
+
if self.validate_crop_dimensions(self.imh.shared):
|
213
|
+
await self._init_auto_crop()
|
214
|
+
else:
|
215
|
+
return image_array
|
205
216
|
if self.imh.auto_crop is None:
|
206
217
|
_LOGGER.debug("%s: Calculating auto trim box", self.file_name)
|
207
218
|
# Find the coordinates of the first occurrence of a non-background color
|
@@ -485,8 +485,13 @@ async def async_resize_image(params: ResizeParams):
|
|
485
485
|
"""Resize the image to the given dimensions and aspect ratio."""
|
486
486
|
if params.aspect_ratio:
|
487
487
|
wsf, hsf = [int(x) for x in params.aspect_ratio.split(",")]
|
488
|
-
|
489
|
-
|
488
|
+
|
489
|
+
if wsf == 0 or hsf == 0 or params.width <= 0 or params.height <= 0:
|
490
|
+
_LOGGER.warning(
|
491
|
+
"Invalid aspect ratio parameters: width=%s, height=%s, wsf=%s, hsf=%s. Returning original image.",
|
492
|
+
params.width, params.height, wsf, hsf)
|
493
|
+
return params.pil_img # Return original image if invalid
|
494
|
+
|
490
495
|
new_aspect_ratio = wsf / hsf
|
491
496
|
if params.width / params.height > new_aspect_ratio:
|
492
497
|
new_width = int(params.pil_img.height * new_aspect_ratio)
|
@@ -495,11 +500,7 @@ async def async_resize_image(params: ResizeParams):
|
|
495
500
|
new_width = params.pil_img.width
|
496
501
|
new_height = int(params.pil_img.width / new_aspect_ratio)
|
497
502
|
|
498
|
-
_LOGGER.debug(
|
499
|
-
"Image Aspect Ratio: %s, %s",
|
500
|
-
str(wsf),
|
501
|
-
str(hsf),
|
502
|
-
)
|
503
|
+
_LOGGER.debug("Resizing image to aspect ratio: %s, %s", wsf, hsf)
|
503
504
|
|
504
505
|
if (params.crop_size is not None) and (params.offset_func is not None):
|
505
506
|
offset = OffsetParams(wsf, hsf, new_width, new_height, params.is_rand)
|
@@ -43,6 +43,7 @@ class HypferMapImageHandler(BaseHandler):
|
|
43
43
|
self.active_zones = None # vacuum active zones.
|
44
44
|
self.svg_wait = False # SVG image creation wait.
|
45
45
|
trim_data = self.shared.trims.to_dict() # trims data
|
46
|
+
_LOGGER.debug("Trim Data: %s", str(trim_data))
|
46
47
|
self.trim_up = trim_data.get("trim_up", 0) # trim up
|
47
48
|
self.trim_down = trim_data.get("trim_down", 0) # trim down
|
48
49
|
self.trim_left = trim_data.get("trim_left", 0) # trim left
|
@@ -53,6 +53,7 @@ class ReImageHandler(BaseHandler):
|
|
53
53
|
self.shared = camera_shared # Shared data
|
54
54
|
self.active_zones = None # Active zones
|
55
55
|
trim_data = self.shared.trims.to_dict() # trims data
|
56
|
+
_LOGGER.debug("Trim Data: %s", trim_data)
|
56
57
|
self.trim_up = trim_data.get("trim_up", 0) # trim up
|
57
58
|
self.trim_down = trim_data.get("trim_down", 0) # trim down
|
58
59
|
self.trim_left = trim_data.get("trim_left", 0) # trim left
|
@@ -258,6 +259,9 @@ class ReImageHandler(BaseHandler):
|
|
258
259
|
return img_np_array
|
259
260
|
|
260
261
|
async def _finalize_image(self, pil_img):
|
262
|
+
if not self.shared.image_ref_width or not self.shared.image_ref_height:
|
263
|
+
_LOGGER.warning("Image finalization failed: Invalid image dimensions. Returning original image.")
|
264
|
+
return pil_img
|
261
265
|
if self.check_zoom_and_aspect_ratio():
|
262
266
|
resize_params = prepare_resize_params(self, pil_img, True)
|
263
267
|
pil_img = await self.async_resize_images(resize_params)
|
@@ -1,20 +1,20 @@
|
|
1
1
|
valetudo_map_parser/__init__.py,sha256=Wmd20bdI1btzMq-0x8NxGYWskTjdUmD-Fem9MTfziwU,810
|
2
2
|
valetudo_map_parser/config/__init__.py,sha256=DQ9plV3ZF_K25Dp5ZQHPDoG-40dQoJNdNi-dfNeR3Zc,48
|
3
|
-
valetudo_map_parser/config/auto_crop.py,sha256=
|
3
|
+
valetudo_map_parser/config/auto_crop.py,sha256=J_1f4W_V1_kbALkWNd2VJosnjjSk5YR3IvHtDGmVGx0,10894
|
4
4
|
valetudo_map_parser/config/colors.py,sha256=IzTT9JvF12YGGJxaTiEJRuwUdCCsFCLzsR9seCDfYWs,6515
|
5
5
|
valetudo_map_parser/config/drawable.py,sha256=hsrEJCMVOrjs5sJfr26SeqJD0VNlYWwxcVkkHeaxx7U,20356
|
6
6
|
valetudo_map_parser/config/rand25_parser.py,sha256=kIayyqVZBfQfAMkiArzqrrj9vqZB3pkgT0Y5ufrQmGA,16448
|
7
7
|
valetudo_map_parser/config/shared.py,sha256=jk7x8xCiE0UnE1oXcZ4iIBGz1Mv0CTHQOeZN2K94eXA,9743
|
8
8
|
valetudo_map_parser/config/types.py,sha256=wcWtYAc5sc9CWYzRJ4aOJRmuvM2rMuCfcDgAhpV8yEM,17144
|
9
|
-
valetudo_map_parser/config/utils.py,sha256=
|
9
|
+
valetudo_map_parser/config/utils.py,sha256=5P33Ren99EUwF7vfQ-GhSeCiR6jI1ZtiKQaofbgIKp8,18914
|
10
10
|
valetudo_map_parser/hypfer_draw.py,sha256=1trtil-CQcDSiAMBWPBmuP5L9MWHGTp5OlY7MX8FgDg,14932
|
11
|
-
valetudo_map_parser/hypfer_handler.py,sha256=
|
11
|
+
valetudo_map_parser/hypfer_handler.py,sha256=ibW2DQSWxCV2PHA6FwfIOIBDu6hryCs7ae6HD-Nhm6A,13635
|
12
12
|
valetudo_map_parser/map_data.py,sha256=6FbQfgxFB6E4kcOWokReJOVSekVaE1kStyhTQhAhiOg,19469
|
13
13
|
valetudo_map_parser/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
-
valetudo_map_parser/rand25_handler.py,sha256=
|
14
|
+
valetudo_map_parser/rand25_handler.py,sha256=nFOX1yVvZrAYxfY-aij7oIz0nKcUUL28y9_gsNJWWLw,15746
|
15
15
|
valetudo_map_parser/reimg_draw.py,sha256=V0JUASavKVnEtAhv7nOV4pjsRxZrNsjIUtctbKO8wvk,12507
|
16
|
-
valetudo_map_parser-0.1.
|
17
|
-
valetudo_map_parser-0.1.
|
18
|
-
valetudo_map_parser-0.1.
|
19
|
-
valetudo_map_parser-0.1.
|
20
|
-
valetudo_map_parser-0.1.
|
16
|
+
valetudo_map_parser-0.1.9b27.dist-info/LICENSE,sha256=Lh-qBbuRV0-jiCIBhfV7NgdwFxQFOXH3BKOzK865hRs,10480
|
17
|
+
valetudo_map_parser-0.1.9b27.dist-info/METADATA,sha256=SzlOLmV3VGgFRnaCjyyqrt2Cn7CIMin6rGGuwt9huyA,1029
|
18
|
+
valetudo_map_parser-0.1.9b27.dist-info/NOTICE.txt,sha256=5lTOuWiU9aiEnJ2go8sc7lTJ7ntMBx0g0GFnNrswCY4,2533
|
19
|
+
valetudo_map_parser-0.1.9b27.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
20
|
+
valetudo_map_parser-0.1.9b27.dist-info/RECORD,,
|
File without changes
|
{valetudo_map_parser-0.1.9b26.dist-info → valetudo_map_parser-0.1.9b27.dist-info}/NOTICE.txt
RENAMED
File without changes
|
File without changes
|