From a0d8e5cb337de3dc921d54a90e0eb4b489da333e Mon Sep 17 00:00:00 2001 From: hugovk Date: Tue, 27 May 2014 12:10:10 +0300 Subject: [PATCH] Set limit to to around a quarter gigabyte for a 24 bit (3 bpp) image --- PIL/Image.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PIL/Image.py b/PIL/Image.py index 7014d36f3..6dd9b2310 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -36,7 +36,8 @@ class _imaging_not_installed: raise ImportError("The _imaging C module is not installed") -MAX_IMAGE_PIXELS = 6000 * 6000 - 1 # FIXME: Pick sensible limit +# Limit to around a quarter gigabyte for a 24 bit (3 bpp) image +MAX_IMAGE_PIXELS = int(1024 * 1024 * 1024 / 4 / 3) try: # give Tk a chance to set up the environment, in case we're @@ -2157,6 +2158,7 @@ def open(fp, mode="r"): # return factory(fp, filename) im = factory(fp, filename) _compression_bomb_check(im.size) + print(im) return im except (SyntaxError, IndexError, TypeError): #import traceback