PIL.Image.DecompressionBombError: Image size exceeds limit of pixels

I am trying to create DSM for tiff files using the below command but its fails with an error:

“docker run -ti --rm -v /home/ubuntu/datasets:/datasets opendronemap/odm --project-path /datasets project --dsm --orthophoto-resolution 2 --ignore-gsd”

Error:

Extracting EXIF for 295899.tif
Traceback (most recent call last):
File “/code/SuperBuild/install/bin/opensfm/opensfm/io.py”, line 1221, in image_size_from_fileobject
with Image.open(fb) as img:
File “/usr/local/lib/python3.9/dist-packages/PIL/Image.py”, line 2929, in open
im = _open_core(fp, filename, prefix, formats)
File “/usr/local/lib/python3.9/dist-packages/PIL/Image.py”, line 2916, in _open_core
_decompression_bomb_check(im.size)
File “/usr/local/lib/python3.9/dist-packages/PIL/Image.py”, line 2828, in _decompression_bomb_check
raise DecompressionBombError(
PIL.Image.DecompressionBombError: Image size (449925840 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.

Welcome!

Sorry you’re having trouble.

Are you able to share the image?

Hi Saijin,

It doesn’t allow to upload .tif file. Any alternate option?

1 Like

dronedb.app or another Cloud Service provider?

Hi Saijin,

Please download it from this location:

1 Like

Dang… 450MP image! I’m surprised it worked at all!

Extent
image

1:1
image

Is it possible for you to downsize it a bit? Looks like 180MP is PIL’s cap at the moment for whatever reason.

1 Like

Hi Saijin,

I am surprised too. Had tried to process this image using following command:

docker run -ti --rm -v /home/ubuntu/datasets:/datasets opendronemap/odm --project-path /datasets project --dsm --orthophoto-resolution 2

Please suggest, if anything is incorrect?

1 Like

I mean you’d have to resize it before passing it to OpenDroneMap. Likely with QGIS.

Are these actual images, or are you trying to composite already composited orthophotos? If it is the latter, you likely will not have sufficient overlap/sidelap and you’re better off using a Mosaic analysis in something like QGIS (which is designed to stitch images together with minimal overlap/sidelap).

These are actual raw images and resizing is not an option because camera parameter needed for DSM calculation will not be applicable.

1 Like

Oh, wow.

Quite the sensor platform! Awesome stuff!

At this point my instinct is we may have to address this upstream in PIL, but I’m out of my depth so that is conjecture.

Please stand by until someone more knowledgeable comes along.

The limitation is hardcoded in the PIL package, we can edit MAX_IMAGE_PIXELS = None in PIL/Image.py to disable it

2 Likes

Is PIL liable to silently break with that option disabled? Will/can it overflow or something?

This variable is only used to check decompression bomb, so it should not break anything, but memory issues could happen since there is no limitation of the image size.

1 Like

Hm, maybe we can patch our ODM-included build for something like 500Mpx so it is capped high but still offers some protection…

1 Like

Hi Saijin,

I tried to build the Docker Image using Dockerfile but it get hangs after a while. Is it possible to share the updated Docker Image with fix?

1 Like

Uhhh… I can try. It’ll take me a while, never done this.

thanks

Yeah, I’m not sure how to modify the Dockerfile to patch the PIL library, so I think I’m going to have to tap out here.

ok, sooner the better it is…

Make the change to the file and then you can docker cp thé file into the correct location in docker image.

1 Like