Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imagemagick throws "width or height exceeds" when converting SVG to PNG with version 6.9.11-60 but not with 6.9.10-23 #6926

Closed
q2apro opened this issue Dec 6, 2023 · 5 comments

Comments

@q2apro
Copy link

q2apro commented Dec 6, 2023

ImageMagick version

6.9.11

Operating system

Linux

Operating system, version and so on

Ubuntu 22.04.3

Description

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?


PS: The problem is NOT the policy.xml - see https://stackoverflow.com/questions/77578848/imagemagick-throws-width-or-height-exceeds-when-converting-svg-to-png-with-ver

@snibgo
Copy link

snibgo commented Dec 6, 2023

Naming your input SVG as medienz.svg, your command:

magick -density 1200 medienz.svg info:

** (process:15860): WARNING **: 13:14:59.964: couldn't load font ""TwCenMT-Regular" Not-Rotated 6.9658203125", falling back to "Sans Not-Rotated 6.9658203125", expect ugly output.
medienz.svg SVG 18237x2837 18237x2837+0+0 16-bit sRGB 3590B 0.000u 0:00.000

... would give a width of 18237 pixels, but your limit in policy.xml is 16000 pixels.

@q2apro
Copy link
Author

q2apro commented Dec 6, 2023

Wow. I am stunned.

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!

@q2apro q2apro closed this as completed Dec 6, 2023
@fmw42
Copy link

fmw42 commented Dec 6, 2023

When you do

convert -density 1200 test.svg x.png

you get and image of dimension 18238 × 2838

So you need a policy that allows for a width of 18238 and height of 2838 and area in pixels of 51,759,444 = 51.8 MP

Your policy is

Width: 16KP
Height: 16KP
Area: 128MP

So your width of 16KP = 16,000 is less than the needed width of 18,238

and your area is 128MP which is less than the needed 51.8 MP.

You have to allow a density that will keep those dimension below your policy limits, even though you resize afterwards. The limits must allow for intermediate images to satisfy as well as your final image.

@q2apro
Copy link
Author

q2apro commented Dec 7, 2023

But it is still a mystery why the old ImageMagick version did the SVG to PNG conversion, with the same settings 16KP.

@fmw42
Copy link

fmw42 commented Dec 7, 2023

There can be 3 different SVG renderers that can be used. Inkscape is best, followed by RSVG delegate. If neither are installed, then the IM internal MSVG/XML renderer is used, which is the least functional. So you may have/had different SVG renderers in use on the two different systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants