From c4e3d040435481b3332bd9ba8e0062d5af467f1d Mon Sep 17 00:00:00 2001 From: waltem01 Date: Fri, 16 Feb 2024 07:11:50 +0100 Subject: [PATCH] resize image on client --- API/main.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/API/main.py b/API/main.py index d28ad35..0c0e151 100755 --- a/API/main.py +++ b/API/main.py @@ -49,15 +49,12 @@ def display_image(): # receive client data data = request.form - # try unpacking image width and height - width = int(data.get('w')) - height = int(data.get('h')) # try unpacking x,y coordinates x_coord = int(data.get('x')) y_coord = int(data.get('y')) # call matrix method with data - matrix.display_image(x_coord, y_coord, width, height) + matrix.display_image(x_coord, y_coord) except Exception as e: # error handling print(e) @@ -295,9 +292,8 @@ class Matrix(SampleBase): self.image = Image.open(requests.get(url, stream=True).raw) # display image at position with dimensions in current color - def display_image(self, x: int, y: int, w: Optional[int] = None, h: Optional[int] = None): - # resize image to specified or max size - self.image.resize((w or self.matrix.width, h or self.matrix.height), Image.ANTIALIAS) + def display_image(self, x: int, y: int): + if self.image is None: return # set image at position self.canvas.SetImage(self.image, x, y)