Error “convert: cache resources exhausted” (SOLVED)
March 22, 2022
When using the convert utility to convert images, you may encounter an error stating that the cache resources have been exhausted.
convert -density 300 -quality 100 input.pdf output.png
An example of the error it causes:
convert-im6.q16: cache resources exhausted `/tmp/magick-q7O_IcbbGpFULs5R34rLlwAyeW1slGHi19' @ error/cache.c/OpenPixelCache/4095.
This error occurs when two conditions are combined:
- processing a large file (for example, when converting PDF to JPG)
- weak computer with little RAM
As a quick fix, you can try reducing the image quality:
convert -density 150 -quality 70 input.pdf output.png
The -density option specifies the horizontal and vertical density of the image, that is, the number of dots. Typically, for scanning photographs, the setting is set to 300 dots – this is enough for good image quality for viewing on a monitor screen and for printing. You can experiment by choosing a lower value.
The -quality option specifies the compression level for JPEG/MIFF/PNG. Option value 100 means no compression, 100% image quality. An option value of 70 means 70% of the image quality by reducing its size.
If you do not want to reduce the quality, then you can try changing the settings. To do this, open the policy.xml file. Depending on your Linux distribution and version of ImageMagick, the path to the file may vary, for example:
Find and edit the string value:
<policy domain="resource" name="memory" value="256MiB"/>
- Error “attempt to perform an operation not allowed by the security policy `PDF'” (SOLVED) (100%)
- How to convert PDF to JPG using command line in Linux (SOLVED) (69.1%)
- How to convert JPG to PDF (69.1%)
- What program to open .docbook files (DocBook) (62.1%)
- Error “convert: delegate failed `'potrace' --svg --output '%o' '%i'' @ error/delegate.c/InvokeDelegate/1911” (SOLVED) (57.6%)
- How to know when the ext4/ext3/ext2 filesystem was created and when it was last mounted (RANDOM - 50%)