1 year ago

#382337

test-img

Valderann

How to prevent excessive memory usage when resizing images with a large dimension?

I'm using a image resizing library for resizing images on a website. To better secure the image resizing process I used a fuzzer(afl fuzz).

One image caused excessive memory. It a GIF image with 65503x65503 dimension. I have used several different image libraries like ImageSharp and SKIASharp and all libraries struggle with these images. A JPEG with a large dimension seems to cause the same issue.

Tried opening these images with these applications to see how they handle those images.

These are the results:

  • Windows photo => Image in a invalid format message
  • Irfanview => hangs
  • GIMP => takes a while and uses up 22gb ram
  • Firefox => black image and large memory usage
  • Chrome => returns a white default image
  • Edge => returns a white default image

The main question is how to properly handle images that have a large dimension without using up excessive memory.

One solution could be to limit opening/resizing an image if exceeds a certain limit. How can you determine that limit?

image-processing

websecurity

0 Answers

Your Answer

Accepted video resources