报错内容:AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

问题所在:
 使用PIL读取图像后对其进行Resize时由于PIL 版本问题出现AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'
 具体的代码如下
resized_img = img.resize(target_size, Image.ANTIALIAS) 
解决方法:
解决方案就是将Image.ANTIALIAS 替换为 Image.LANCZOS 或 Image.Resampling.LANCZOS
resized_img = img.resize(target_size, Image.LANCZOS) 
分析原因:
在新版本pillow(10.0.0之后)Image.ANTIALIAS 被移除了,取而代之的是Image.LANCZOS or Image.Resampling.LANCZOS,相关描述可以可以在pillow的发行说明中查到。

学习自这位大佬
也是补充自己的知识,以备以后遇到问题能够解决



















