skip to Main Content

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


  1. Chosen as BEST ANSWER

    Changed these lines:

      <policy domain="resource" name="width" value="16KP"/>
      <policy domain="resource" name="height" value="16KP"/>
    

    to

      <policy domain="resource" name="width" value="32KP"/>
      <policy domain="resource" name="height" value="32KP"/>
    

    Now it works. Thanks a thousand @snibgo. Credits: https://github.com/ImageMagick/ImageMagick/issues/6926


  2. 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. The Area limit is the maximum width * height of an image that can be processed. It’s specified in your policy.xml file and can also be viewed using convert -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 to 512MP instead of 128MB or 128MP. 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:

    # Open your policy.xml file.
    sudo nano /etc/ImageMagick-6/policy.xml
    
    # Find the line with <policy domain="resource" name="area" value="128MP"/>.
    # Change it to <policy domain="resource" name="area" value="512MP"/>.
    # Save the file and exit.
    # Restart ImageMagick.
    sudo service imagemagick restart
    
    
    Please try this and see if it resolves your issue. If the problem persists, it might be worth checking if there are other differences in the configuration between your two servers. Also, ensure that the SVG file you’re trying to convert doesn’t have dimensions that exceed the Width and Height resource limits.
    

    I hope this helps!

    References:

    ImageMagick Resource Limits

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search