首页 > 其他分享 >AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

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

时间:2023-09-25 15:37:08浏览次数:33  
标签:PIL no attribute Image ANTIALIAS im LANCZOS

错误由来

im = im.resize((w, h), Image.ANTIALIAS)

Traceback (most recent call last):
  AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'
import PIL
print(PIL.__version__)
10.0.1

原因是在pillow的10.0.0版本中,ANTIALIAS方法被删除了,使用新的方法即可:

Image.LANCZOS
Image.Resampling.LANCZOS

解决办法

方案一,修改方法调用,将其中的ANTIALIAS替换为LANCZOS

# im = im.resize((w, h), Image.ANTIALIAS)
im = im.resize((w, h), Image.LANCZOS)

方案二,降级Pillow的版本,如9.5.0版本

卸载再重新安装

pip uninstall -y Pillow
pip install Pillow==9.5.0

标签:PIL,no,attribute,Image,ANTIALIAS,im,LANCZOS
From: https://www.cnblogs.com/echohye/p/17728018.html

相关文章

  • OGG MA - Not Able To Log InAdmin server ERROR: User name 'oggadmin' or password
    ogg的密码文件可能会损坏需要修复就新建一个新的ogg微服务并且把密码文件考到问问题的地方进行覆盖,我觉得这个是一个bugTherecommendationistoCreateadummyMAinstallationonthesameserverordifferenttestserver.Thencopythewallet[cwallet.sso]fromthis......
  • Uncaught TypeError: Cannot read properties of undefined (reading 'form')问题的解
    问题描述使用vue3执行数据添加操作时,发现了这个错误,使用测试按钮拿文本框数据,一直报错拿不到:问题解决原来是vue2在执行这个操作时:里面放this.form;而vue3在执行这个操作时,里面放的却是:form......
  • maven 问题之 no POM in this directory
    Windows上mvninstall:install-file报:noPOMinthisdirectory1、问题再现.2、解决方案方案一:.然后输入mvn命令即可mvninstall:install-file-DgroupId=com.rnny-DartifactId=rnny-tools-common-Dversion=1.0-SNAPSHOT-Dpackaging=jar-Dfile=./rnny-tools-commo......
  • Anaconda-CondaError: Downloaded bytes did not match Content-Length
    遇到如下情况:CondaError:DownloadedbytesdidnotmatchContent-Length,换源!condaconfig--addchannelshttps://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/condaconfig--addchannelshttps://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/#设置搜索时显......
  • 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains n
    博客园首页新随笔联系管理订阅随笔-111 文章-1 评论-3 阅读-17万 1055-Expression#1ofORDERBYclauseisnotinGROUPBYclauseandcontainsnonaggregatedcolumn'information_schema.PROFILING.SEQ'whichisnotfunctionally......
  • Python dataclass 如何让传入的 field 为 None 时自动转化为默认值?
    一般dataclass的字段可以设置default或default_factory生成默认值,当传入参数时,默认值不会生效。但是,有些情况下受限于外部调用环境,某些参数缺失时,以None的形式存在,而非创建dataclass实例时不传入参数。这种情况下,可能会希望传入的None被识别到并转化为默认值。fromd......
  • Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate
    MySQL有any_value(field)函数,他主要的作用就是抑制ONLY_FULL_GROUP_BY值被拒绝官方有介绍,地址:https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_any-value我们可以把select语句中查询的属性(除聚合函数所需的参数外),全部放入any_value(field)函数......
  • Logstash报错: Could not index event to Elasticsearch
    Logstash报错:CouldnotindexeventtoElasticsearch 一、环境说明Logstash7.3ElasticSearch7.3二、现象logstash/logs/logstash-plain.log大量警告:ValidationFailed:1:thisactionwouldadd[1]totalshards,butthisclustercurrentlyhas[1000]/[1000]maximum......
  • 17.云市场: 基于OpenStack的Murano模块,开发一个云市场,允许用户发现和部署云应用程序
    基于OpenStack的Murano模块,开发一个云市场可以让用户发现、选择和部署云应用程序。Murano是OpenStack的应用程序目录和部署引擎,它可以用于创建和管理云应用程序的目录、模板和部署。以下是一个简化的示例,演示如何使用Murano来构建这样一个云市场。注意:为了构建这个示例,你需要一个......
  • P4425 HNOI/AHOI2018 转盘
    Day21。容易发现最优解里一定存在一种方案,为「一开始停留一段时间,然后一直往下一个取」的形式。通过调整容易证明。断环成链,直接列出式子:\[\text{ans}=\min\limits_{n\lei<2n}\max\limits_{i-n<j\lei}a_j-j+i\]令\(t_i=a_i-i(1\lei\le2n)\),然后让\(i\)平移\(n-1\)......