Skip to content

Update PIllow's image size limits through an environment variable

https://redmine.teklia.com/issues/8024

To handle very large images, the file import needs to support a new ARKINDEX_MAX_IMAGE_PIXELS environment variable. When it is set to any integer, it should change the value of Pillow's Image.MAX_IMAGE_PIXELS, to change the detection of decompression bombs.

If it is not set, or set to an empty string, the setting should not be changed. If it is set to 0, MAX_IMAGE_PIXELS should be None to disable the limit entirely. No error handling is necessary for non-integer values; we trust the sysadmins.

You can put this under FileImport.run(), with a warning log if the limit is completely disabled.