akamhy / imagedominantcolor

Get the dominant color of any image
https://pypi.org/project/imagedominantcolor/
MIT License
5 stars 7 forks source link

(Pillow Error) AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS' #4

Open ShivamA96 opened 9 months ago

ShivamA96 commented 9 months ago
def __init__(self, image_path: str) -> None:
        self.image_path = image_path
        self.image = Image.open(self.image_path)
        self.dominant_color: str = ""
        self.r: int = 0
        self.g: int = 0
        self.b: int = 0
        self.l: int = 0
        self.resized_image = self.image.resize(
            **(DominantColor.resize_value, DominantColor.resize_value), Image.ANTIALIAS**
        ).convert("RGBA")
        self.image.close()
        self.image_data = self.resized_image.getdata()
        self.generate_dominant_color_of_pixels_of_image_array()
        self.resized_image.close()
gilbert-houtekamer commented 3 weeks ago

I get the same error, copilot sys:

[The error message you’re encountering indicates that the attribute 'ANTIALIAS' is no longer available in Pillow (PIL) starting from version 10.0.0. Instead, you should use 'LANCZOS' for antialiasing when resizing images.

Demmenie commented 5 days ago

I have fixed this in my fork of this package called "imagedominantcolour": https://github.com/Demmenie/imagedominantcolour https://pypi.org/project/imagedominantcolour/