Pillow in Python won't let me open image ("exceeds limit")

Try

PIL.Image.MAX_IMAGE_PIXELS = 933120000

How to find out such a thing?

import PIL
print(PIL.__file__)  # prints, e. g., /usr/lib/python3/dist-packages/PIL/__init__.py

Then

cd /usr/lib/python3/dist-packages/PIL
grep -r -A 2 'exceeds limit' .

prints

./Image.py:            "Image size (%d pixels) exceeds limit of %d pixels, "
./Image.py-            "could be decompression bomb DOS attack." %
./Image.py-            (pixels, MAX_IMAGE_PIXELS),

Then

grep -r MAX_IMAGE_PIXELS .

prints

./Image.py:MAX_IMAGE_PIXELS = int(1024 * 1024 * 1024 / 4 / 3)
./Image.py:    if MAX_IMAGE_PIXELS is None:
./Image.py:    if pixels > MAX_IMAGE_PIXELS:
./Image.py:            (pixels, MAX_IMAGE_PIXELS),

Then

python3
import PIL.Image
PIL.Image.MAX_IMAGE_PIXELS = 933120000

Works without complaint and fixes your issue.


After the imports, add :

Image.MAX_IMAGE_PIXELS = None