Rishabh Malhotra
Rishabh Malhotra

Reputation: 13

Converting a very high res image to a numpy array

I want to convert a very high resolution png image to a numpy array, but I'm getting limit exceed error.

I'm using the PIL library to read the image, and using np.save to save the array. I want to know if there is a way to exceed this limit, or convert the image by using some other libraries.

I = np.array(Image.open(filepath), dtype = 'int8') np.save(outfile_path, I)

Error Message: PIL.Image.DecompressionBombError: Image size (515558400 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.

Upvotes: 0

Views: 881

Answers (1)

Priyatham
Priyatham

Reputation: 2897

Set MAX_IMAGE_PIXELS to None to disable the limit on image size. (Warning: Do this only if you trust where you are getting the images from)

from PIL import Image
Image.MAX_IMAGE_PIXELS = None

Upvotes: 2

Related Questions