mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Cast width / height to integer (#7676)
* Cast width / height to integer * Convert "rotate" parameter
This commit is contained in:
parent
58807d575c
commit
ecec81ead0
@ -170,6 +170,18 @@ def uploaded_image(
|
||||
width = kwargs.get('width', None)
|
||||
height = kwargs.get('height', None)
|
||||
|
||||
if width is not None:
|
||||
try:
|
||||
width = int(width)
|
||||
except ValueError:
|
||||
width = None
|
||||
|
||||
if height is not None:
|
||||
try:
|
||||
height = int(height)
|
||||
except ValueError:
|
||||
height = None
|
||||
|
||||
if width is not None and height is not None:
|
||||
# Resize the image, width *and* height are provided
|
||||
img = img.resize((width, height))
|
||||
@ -185,10 +197,12 @@ def uploaded_image(
|
||||
img = img.resize((wsize, height))
|
||||
|
||||
# Optionally rotate the image
|
||||
rotate = kwargs.get('rotate', None)
|
||||
|
||||
if rotate is not None:
|
||||
if rotate := kwargs.get('rotate', None):
|
||||
try:
|
||||
rotate = int(rotate)
|
||||
img = img.rotate(rotate)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# Return a base-64 encoded image
|
||||
img_data = report.helpers.encode_image_base64(img)
|
||||
|
Loading…
Reference in New Issue
Block a user