Force ImageMagick to use RAM with very large images

less than 1 minute read

I use NEXRAD PNG preview data in my atmospheric research work, and the NEXRAD PNGs are 12200 x 5400 pixels. This takes over 650 MB of RAM to process.


Normally, you should be able to control ImageMagick use of RAM with environment variables:

  • MAGICK_MEMORY_LIMIT Amount of RAM heap to use
  • MAGICK_MAP_LIMIT Amount of RAM to use before paging to disk
  • MAGICK_DISK_LIMIT A very slow last resort, before crashing.

I tried commands like


but they still paged to disk, taking 1000x longer even with SSD (and wearing the heck out of the SSD with writes).

MAGICK_DISK_LIMIT=100MB mogrify -scale 10% "*.png"

would give error message as expected.

I filed an ImageMagick bug report on this.


For Linux, there is a RAM drive available at /dev/shm or /run/shm, which is not available on Windows, even with Cygwin or Windows Subsystem for Linux.

I force ImageMagick to use RAM drive, which gave me 1000x speedup by:

MAGICK_TEMPORARY_PATH=/run/shm mogrify -scale 10% "*.png"

Leave a Comment