Merge pull request #6539 from PySimpleGUI/Dev-latest

Replaced PIL's deprecated constant ANTIALIAS with LANCZOS
This commit is contained in:
PySimpleGUI 2023-10-05 16:12:38 -04:00 committed by GitHub
commit 03ed1948e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 16 additions and 16 deletions

View File

@ -26,7 +26,7 @@ def resize_base64_image(image64, size):
'''
image_file = io.BytesIO(base64.b64decode(image64))
img = Image.open(image_file)
img.thumbnail(size, Image.ANTIALIAS)
img.thumbnail(size, Image.LANCZOS)
bio = io.BytesIO()
img.save(bio, format='PNG')
imgbytes = bio.getvalue()

View File

@ -81,7 +81,7 @@ def convert_to_bytes(source, size=(None, None), subsample=None, zoom=None, fill=
elif zoom is not None:
scale = zoom
resized_image = image.resize((int(width * scale), int(height * scale)), Image.ANTIALIAS) if scale is not None else image
resized_image = image.resize((int(width * scale), int(height * scale)), Image.LANCZOS) if scale is not None else image
if fill and scale is not None:
resized_image = make_square(resized_image)
# encode a PNG formatted version of image into BASE64

View File

@ -92,7 +92,7 @@ def convert_to_bytes(file_or_bytes, resize=None, fill=False):
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)
if fill:
if resize is not None:
img = make_square(img, resize[0])

View File

@ -44,7 +44,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)
bio = io.BytesIO()
img.save(bio, format="PNG")
del img

View File

@ -45,7 +45,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

View File

@ -55,7 +55,7 @@ def resize(input_file, size, output_file=None, encode_format='PNG'):
new_width, new_height = size
if new_width != width or new_height != height: # if the requested size is different than original size
scale = min(new_height / height, new_width / width)
resized_image = image.resize((int(width * scale), int(height * scale)), Image.ANTIALIAS)
resized_image = image.resize((int(width * scale), int(height * scale)), Image.LANCZOS)
else:
resized_image = image

View File

@ -56,7 +56,7 @@ def convert_to_bytes(file_or_bytes, resize=None, fill=False):
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)
if fill:
img = make_square(img, THUMBNAIL_SIZE[0])
with io.BytesIO() as bio:

View File

@ -890,7 +890,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

View File

@ -15,7 +15,7 @@ button64 = 'iVBORw0KGgoAAAANSUhEUgAAAoAAAAFACAMAAAAbEz04AAAABGdBTUEAALGPC/xhBQAA
def image_file_to_bytes(image64, size):
image_file = io.BytesIO(base64.b64decode(image64))
img = Image.open(image_file)
img.thumbnail(size, Image.ANTIALIAS)
img.thumbnail(size, Image.LANCZOS)
bio = io.BytesIO()
img.save(bio, format='PNG')
imgbytes = bio.getvalue()

View File

@ -60,7 +60,7 @@ def convert_to_bytes(source, size=(None, None), subsample=None, zoom=None, fill=
elif zoom is not None:
scale = zoom
resized_image = image.resize((int(width * scale), int(height * scale)), Image.ANTIALIAS) if scale is not None else image
resized_image = image.resize((int(width * scale), int(height * scale)), Image.LANCZOS) if scale is not None else image
if fill and scale is not None:
resized_image = make_square(resized_image)
# encode a PNG formatted version of image into BASE64

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()

View File

@ -29,7 +29,7 @@ def resize_base64_image(image64, size):
"""
image_file = io.BytesIO(base64.b64decode(image64))
img = Image.open(image_file)
img.thumbnail(size, Image.ANTIALIAS)
img.thumbnail(size, Image.LANCZOS)
bio = io.BytesIO()
img.save(bio, format='PNG')
imgbytes = bio.getvalue()

View File

@ -2664,7 +2664,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)
bio = io.BytesIO()
img.save(bio, format="PNG")
del img
@ -2747,7 +2747,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)
bio = io.BytesIO()
img.save(bio, format="PNG")
del img