欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

exceeds limit of 89478485 pixels, could be decompression bomb DOS attack.

程序员文章站 2024-02-08 18:01:16
...

Python PIL读图出现上述问题。
原因提示很明确,就是因为图片太大了,可能被解压炸弹DOS攻击。
问题出现的本质是一个警告。

PIL is merely trying to protect you. It’ll not open larger images, as that could be a vector of attack for a malicious user to give you a large image that’ll expand to use up all memory.

Since you are not a malicious user and are not accepting images from anyone else, you can simply disable the limit:

可以直接不检查图片大小,利用如下代码设置。

from PIL import Image

Image.MAX_IMAGE_PIXELS = None

英文解释出处

其他可行方案:
经过网上搜集资料
could be decompression bomb DOS attack可以按照这里利用这个工具GDAL - Geospatial Data Abstraction Library