I have one server with Ubuntu 20.4 and ImageMagick 6.9.10-23.
The newer server is with Ubuntu 22.04.3 LTS and ImageMagick 6.9.11-60.
I upload a SVG file and want to convert it to PNG and resize it.
convert -format png -density 1200 -resize '255x255>' /folder/test.svg /folder/test.png
With the old server it works flawlessly.
The newer server with ImageMagick 6.9.11-60 throws:
convert-im6.q16: width or height exceeds limit /tmp/magick-IXLGAi-fnZE2OS1MPM_W1DzbcXjNnrdl @ error/cache.c/OpenPixelCache/3909.
convert-im6.q16: no images defined /srv/users/hessen/apps/edumaps/public/temp/temp.png @ error/convert.c/ConvertImageCommand/3229.
I have compared both /etc/ImageMagick-6/policy.xml
files, they have the same settings. Only the old policy.xml states:
<policy domain="resource" name="area" value="128MB"/>
And the new one states:
<policy domain="resource" name="area" value="128MP"/>
I changed it to 128MB
but still the same error message.
I also check with convert -list resource
. The output is for both servers identical, just the old server states List length: 18.446744EP
and the new server states List length: unlimited
.
Resource limits:
Width: 16KP
Height: 16KP
List length: unlimited
Area: 128MP
Memory: 256MiB
Map: 512MiB
Disk: 1GiB
File: 768
Thread: 64
Throttle: 0
Time: unlimited
Limits can be seen at the docs. But I use the same file on both servers.
The SVG file is 744 x 1052 pixels.
How to fix this problem?
2
Answers
Changed these lines:
to
Now it works. Thanks a thousand @snibgo. Credits: https://github.com/ImageMagick/ImageMagick/issues/6926
The error message you’re encountering is related to ImageMagick’s resource limits. Specifically, the "width or height exceeds limit" error occurs when the pixel cache can’t be opened, which happens when an image’s dimensions exceed ImageMagick’s resource limits.
In your case, the issue seems to be with the
Area
resource limit. TheArea
limit is the maximum width * height of an image that can be processed. It’s specified in yourpolicy.xml
file and can also be viewed usingconvert -list resource
. In ImageMagick,Area
is specified in pixels (P) or bytes (B), not in megabytes (MB). So,128MB
might be causing the confusion.One of the suggestions from the StackOverflow thread is to try changing the
Area
limit to512MP
instead of128MB
or128MP
. Please note that if this is a shared system, you can only decrease the limits. To increase them, the system administrator or ISP would need to do that.Here’s how you can change it:
I hope this helps!
References:
ImageMagick Resource Limits