Replaced PIL's deprecated constant ANTIALIAS with LANCZOS

This commit is contained in:
PySimpleGUI 2023-10-05 16:11:51 -04:00
parent ddebd7a5c6
commit 3776730709
13 changed files with 16 additions and 16 deletions

View file

@ -59,7 +59,7 @@ def convert_to_bytes(file_or_bytes, resize=None):
if resize:
new_width, new_height = resize
scale = min(new_height / cur_height, new_width / cur_width)
img = img.resize((int(cur_width * scale), int(cur_height * scale)), PIL.Image.ANTIALIAS)
img = img.resize((int(cur_width * scale), int(cur_height * scale)), PIL. Image.LANCZOS)
with io.BytesIO() as bio:
img.save(bio, format="PNG")
del img
@ -69,7 +69,7 @@ def convert_to_bytes(file_or_bytes, resize=None):
# def image_file_to_bytes(filename, size):
# try:
# image = Image.open(filename)
# image.thumbnail(size, Image.ANTIALIAS)
# image.thumbnail(size, Image.LANCZOS)
# bio = io.BytesIO() # a binary memory resident stream
# image.save(bio, format='PNG') # save image as png to it
# imgbytes = bio.getvalue()
@ -80,7 +80,7 @@ def convert_to_bytes(file_or_bytes, resize=None):
def set_image_to_blank(key):
img = PIL.Image.new('RGB', (100, 100), (255, 255, 255))
img.thumbnail((1, 1), PIL.Image.ANTIALIAS)
img.thumbnail((1, 1), PIL. Image.LANCZOS)
bio = io.BytesIO()
img.save(bio, format='PNG')
imgbytes = bio.getvalue()