From 9caab9380de707518b9efc7e4dde8d998fb0b9d9 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" <128333288+ltdrdata@users.noreply.github.com> Date: Sat, 8 Jul 2023 15:36:48 +0900 Subject: [PATCH] fix: Image.ANTIALIAS is no longer available. (#847) * modify deprecated api call * prevent breaking old Pillow users * change LANCZOS to BILINEAR --- latent_preview.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/latent_preview.py b/latent_preview.py index 1d143339..833e6822 100644 --- a/latent_preview.py +++ b/latent_preview.py @@ -3,7 +3,6 @@ from PIL import Image, ImageOps from io import BytesIO import struct import numpy as np - from comfy.cli_args import args, LatentPreviewMethod from comfy.taesd.taesd import TAESD import folder_paths @@ -16,7 +15,13 @@ class LatentPreviewer: def decode_latent_to_preview_image(self, preview_format, x0): preview_image = self.decode_latent_to_preview(x0) - preview_image = ImageOps.contain(preview_image, (MAX_PREVIEW_RESOLUTION, MAX_PREVIEW_RESOLUTION), Image.ANTIALIAS) + + if hasattr(Image, 'Resampling'): + resampling = Image.Resampling.BILINEAR + else: + resampling = Image.ANTIALIAS + + preview_image = ImageOps.contain(preview_image, (MAX_PREVIEW_RESOLUTION, MAX_PREVIEW_RESOLUTION), resampling) preview_type = 1 if preview_format == "JPEG":