Convert gives cache errors - did not in April

I use convert to merge 68 pages of jpg images (about 156MB) into a pdf.

I did this dozens of times as recently as April 2025.

I tried to do it today and only get about 23 images in the pdf and get a cache error.

I edited /etc/ImageMagic-7/policy.xml as suggested on the internet - It used to work with no changes.

I doubled every constant 8 to 16, 256 to 512, etc - no change I even up the memory to 3 GiB but no change.

How do I get it to work like ImageMagick-6 did?

I could reproduce something:

$ convert DSC0665?.JPG DSC0664?.JPG /tmp/ramdisk/document.pdf
WARNING: The convert command is deprecated in IMv7, use "magick" instead of "convert" or "magick convert"
convert: cache resources exhausted `DSC06654.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06655.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06656.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06657.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06658.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06659.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06640.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06641.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06642.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06643.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06644.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06645.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06646.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06647.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06648.JPG' @ error/cache.c/OpenPixelCache/3917.
convert: cache resources exhausted `DSC06649.JPG' @ error/cache.c/OpenPixelCache/3917.
$ magick DSC0665?.JPG DSC0664?.JPG /tmp/ramdisk/document.pdf
magick: cache resources exhausted `DSC06654.JPG' @ error/cache.c/OpenPixelCache/3917.
$ lsa /tmp/ramdisk/
total 20692
20644 -rw-r--r--  1 marel marel 21138607 Aug 14 07:18 document.pdf
$ okular /tmp/ramdisk/document.pdf

That document shows only 3 pages.

Interesting to see magick gives different output the convert, magick convert gives the same output as convert.

I even tried that stack overflow - every attempt gives the same 20 pages and cache error

my file

sed -i '/disable ghostscript format types/,+6d' /etc/ImageMagick-7/policy.xml #this one is just to solve convertion from .tiff to pdf, you may need it some day
sed -i -E 's/name="memory" value=".+"/name="memory" value="8GiB"/g' /etc/ImageMagick-7/policy.xml
sed -i -E 's/name="map" value=".+"/name="map" value="8GiB"/g' /etc/ImageMagick-7/policy.xml
sed -i -E 's/name="area" value=".+"/name="area" value="8GiB"/g' /etc/ImageMagick-7/policy.xml
sed -i -E 's/name="disk" value=".+"/name="disk" value="8GiB"/g' /etc/ImageMagick-7/policy.xml

???

You have to change in the file f. e.
disk from 1GB to 8GB

This is the line in my policy.xml:
grep -i ‘“disk” value=’ /etc/ImageMagick-7/policy.xml
<policy domain="resource" name="disk" value="8GiB"/>

What you have posted are 5 separate commands executed as root.

That is what the cache resource ImageMagick stackoverflow.com post said was a fix. I did that as well. I saved the original copy of policy.xml as policy.ori so I could undo every change if I needed to.

No matter what values I put in, the selection with 68 images it cache errors after 20 pages. The weird part is if I tried one with 168 images, it makes it to 108 pages before the cache error. Every image is about a 2MB image.

Why did the ImageMagick-5 have no issues with the default values and ImageMagick-7 fail no matter what is in the policy.xml.

Post:

ls -al /etc/ImageMagick-7/

Also try for disk 12GB instead of 8GB…

> ls -al /etc/ImageMagick-7/
total 396
drwxr-xr-x   2 root root   4096 Aug 14 07:00 .
drwxr-xr-x 174 root root  16384 Aug 13 11:29 ..
-rw-r--r--   1 root root   1383 Jul 16 04:49 colors.xml
-rw-r--r--   1 root root  13337 Jul 16 04:49 delegates.xml
-rw-r--r--   1 root root  52531 Jul 16 04:49 english.xml
-rw-r--r--   1 root root  55403 Jul 16 04:49 francais.xml
-rw-r--r--   1 root root   2461 Jul 16 04:49 locale.xml
-rw-r--r--   1 root root   1642 Jul 16 04:49 log.xml
-rw-r--r--   1 root root 134852 Jul 16 04:49 mime.xml
-rw-r--r--   1 root root   6835 Jul 16 04:49 policy.ori
-rw-r--r--   1 root root   6835 Aug 14 07:00 policy.xml
-rw-r--r--   1 root root   2369 Jul 16 04:49 quantization-table.xml
-rw-r--r--   1 root root  11452 Jul 16 04:49 thresholds.xml
-rw-r--r--   1 root root  29218 Jul 16 04:49 type-apple.xml
-rw-r--r--   1 root root   8490 Jul 16 04:49 type-dejavu.xml
-rw-r--r--   1 root root   9544 Jul 16 04:49 type-ghostscript.xml
-rw-r--r--   1 root root   8162 Jul 16 04:49 type-urw-base35.xml
-rw-r--r--   1 root root  13706 Jul 16 04:49 type-windows.xml
-rw-r--r--   1 root root    612 Jul 16 04:49 type.xml

Test with ImageMagick 7.1.2.0 from Experimental Graphics repo:

https://software.opensuse.org/package/ImageMagick

Also post:

diff -Naur /etc/ImageMagick-7/policy.xml /etc/ImageMagick-7/policy.ori
# diff -Naur /etc/ImageMagick-7/policy.xml /etc/ImageMagick-7/policy.ori
--- /etc/ImageMagick-7/policy.xml	2025-08-14 07:00:49.127284223 -0500
+++ /etc/ImageMagick-7/policy.ori	2025-07-16 04:49:34.000000000 -0500
@@ -48,18 +48,18 @@
   <!-- Set maximum amount of memory in bytes to allocate for the pixel cache
        from the heap. When this limit is exceeded, the image pixels are cached
        to memory-mapped disk. -->
-  <policy domain="resource" name="memory" value="8GiB"/>
+  <policy domain="resource" name="memory" value="256MiB"/>
   <!-- Set maximum amount of memory map in bytes to allocate for the pixel
        cache. When this limit is exceeded, the image pixels are cached to
        disk. -->
-  <policy domain="resource" name="map" value="8GiB"/>
+  <policy domain="resource" name="map" value="512MiB"/>
   <!-- Set the maximum width * height of an image that can reside in the pixel
        cache memory. Images that exceed the area limit are cached to disk. -->
-  <policy domain="resource" name="area" value="8GiB"/>
+  <policy domain="resource" name="area" value="16KP"/>
   <!-- Set maximum amount of disk space in bytes permitted for use by the pixel
        cache. When this limit is exceeded, the pixel cache is not be created
        and an exception is thrown. -->
-  <policy domain="resource" name="disk" value="8GiB"/>
+  <policy domain="resource" name="disk" value="1GiB"/>
   <!-- Set the maximum length of an image sequence.  When this limit is
        exceeded, an exception is thrown. -->
   <policy domain="resource" name="list-length" value="128"/>
#

What about this change only:

<policy domain="resource" name="disk" value="12GiB"/>

Yesterday the same error on converting 100 jpg’s to a pdf, but after this change I was able to do so.

ILL policy was changed to use disk, and then available disk limit was also shrinked?!

IMHO this worths bug report.

I got it to work also with these values - threads seem to be ignored as I set it to 8 and got 1

> convert -list resourceResource limits:
  Width: 12000P
  Height: 12000P
  Area: 15.0324GP
  List length: 512B
  Memory: 14GiB
  Map: 14GiB
  Disk: 14GiB
  File: 768
  Thread: 1
  Throttle: 0
  Time: 4 minutes
>

# diff -Naur /etc/ImageMagick-7/policy.xml /etc/ImageMagick-7/policy.ori
--- /etc/ImageMagick-7/policy.xml	2025-08-14 12:22:57.162429225 -0500
+++ /etc/ImageMagick-7/policy.ori	2025-07-16 04:49:34.000000000 -0500
@@ -37,10 +37,10 @@
 -->
 <policymap>
   <!-- Set maximum parallel threads. -->
-  <policy domain="resource" name="thread" value="8"/>
+  <policy domain="resource" name="thread" value="2"/>
   <!-- Set maximum time in seconds. When this limit is exceeded, an exception
        is thrown and processing stops. -->
-  <policy domain="resource" name="time" value="240"/>
+  <policy domain="resource" name="time" value="120"/>
   <!-- Set maximum number of open pixel cache files. When this limit is
        exceeded, any subsequent pixels cached to disk are closed and reopened
        on demand. -->
@@ -48,27 +48,27 @@
   <!-- Set maximum amount of memory in bytes to allocate for the pixel cache
        from the heap. When this limit is exceeded, the image pixels are cached
        to memory-mapped disk. -->
-  <policy domain="resource" name="memory" value="14GiB"/>
+  <policy domain="resource" name="memory" value="256MiB"/>
   <!-- Set maximum amount of memory map in bytes to allocate for the pixel
        cache. When this limit is exceeded, the image pixels are cached to
        disk. -->
-  <policy domain="resource" name="map" value="14GiB"/>
+  <policy domain="resource" name="map" value="512MiB"/>
   <!-- Set the maximum width * height of an image that can reside in the pixel
        cache memory. Images that exceed the area limit are cached to disk. -->
-  <policy domain="resource" name="area" value="14GiB"/>
+  <policy domain="resource" name="area" value="16KP"/>
   <!-- Set maximum amount of disk space in bytes permitted for use by the pixel
        cache. When this limit is exceeded, the pixel cache is not be created
        and an exception is thrown. -->
-  <policy domain="resource" name="disk" value="14GiB"/>
+  <policy domain="resource" name="disk" value="1GiB"/>
   <!-- Set the maximum length of an image sequence.  When this limit is
        exceeded, an exception is thrown. -->
-  <policy domain="resource" name="list-length" value="512"/>
+  <policy domain="resource" name="list-length" value="128"/>
   <!-- Set the maximum width of an image.  When this limit is exceeded, an
        exception is thrown. -->
-  <policy domain="resource" name="width" value="12KP"/>
+  <policy domain="resource" name="width" value="8KP"/>
   <!-- Set the maximum height of an image.  When this limit is exceeded, an
        exception is thrown. -->
-  <policy domain="resource" name="height" value="12KP"/>
+  <policy domain="resource" name="height" value="8KP"/>
   <!-- Periodically yield the CPU for at least the time specified in
        milliseconds. -->
   <!-- <policy domain="resource" name="throttle" value="2"/> -->
#

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.