diff --git a/src/PIL/Image.py b/src/PIL/Image.py index a770488b7ec..f980bb241a9 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1561,7 +1561,7 @@ def has_transparency_data(self) -> bool: """ return ( self.mode in ("LA", "La", "PA", "RGBA", "RGBa") - or (self.mode == "P" and self.palette.mode.endswith("A")) + or (self.mode == "P" and self.palette and self.palette.mode.endswith("A")) or "transparency" in self.info )