mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-25 11:31:46 +00:00
resize image on client
This commit is contained in:
parent
bc37cb3c67
commit
c4e3d04043
10
API/main.py
10
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user