AttributeError: module ‘PIL.Image‘ has no attribute ‘ANTIALIAS‘

问题描述

修改图片大小的时候,代码报错:AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

解决方案

在pillow的10.0.0版本中,ANTIALIAS方法被删除了。

方法1:修改版本(不推荐)

pip install Pillow==9.5.0

方法2:修改代码

img = img.resize((216, 216), Image.ANTIALIAS)

修改为:

img = img.resize((216, 216), Image.LANCZOS)

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-13 05:00:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-13 05:00:04       101 阅读
  3. 在Django里面运行非项目文件

    2024-05-13 05:00:04       82 阅读
  4. Python语言-面向对象

    2024-05-13 05:00:04       91 阅读

热门阅读

  1. 算法训练营day34

    2024-05-13 05:00:04       30 阅读
  2. Qt 类的设计思路详解

    2024-05-13 05:00:04       34 阅读
  3. 8.Redis

    8.Redis

    2024-05-13 05:00:04      33 阅读
  4. 【面经】Linux

    2024-05-13 05:00:04       33 阅读
  5. LeetCode 每日一题 2024/5/6-2024/5/12

    2024-05-13 05:00:04       30 阅读
  6. XMl发展前景及相关领域

    2024-05-13 05:00:04       31 阅读
  7. 第1章 信息系统综合知识 1.4 IT战略

    2024-05-13 05:00:04       31 阅读