2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 20:15:44 +00:00

Fix argument name (#7653)

* Fix argument name

* Fix typo
This commit is contained in:
Oliver
2024-07-15 13:54:29 +10:00
committed by GitHub
parent 38ad83e401
commit fc0a860e9b
2 changed files with 6 additions and 6 deletions

View File

@ -78,21 +78,21 @@ def report_page_size_default():
return page_size
def encode_image_base64(image, format: str = 'PNG'):
def encode_image_base64(image, img_format: str = 'PNG'):
"""Return a base-64 encoded image which can be rendered in an <img> tag.
Arguments:
image: {Image} -- Image to encode
format: {str} -- Image format (default = 'PNG')
img_format: {str} -- Image format (default = 'PNG')
Returns:
str -- Base64 encoded image data e.g. 'data:image/png;base64,xxxxxxxxx'
"""
fmt = format.lower()
img_format = str(img_format).lower()
buffered = io.BytesIO()
image.save(buffered, fmt)
image.save(buffered, img_format)
img_str = base64.b64encode(buffered.getvalue())
return f'data:image/{fmt};charset=utf-8;base64,' + img_str.decode()
return f'data:image/{img_format};charset=utf-8;base64,' + img_str.decode()