identify hits an infinite loop with some SVG files.

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
matheweis

identify hits an infinite loop with some SVG files.

Post by matheweis »

When operating on some SVG files, imagemagick seems to enter an infinite loop, and creates an infinitely large file in /tmp/

A copy of an example SVG files causing the problem can be found here:
http://www.eisbox.net/tmp/graph.svg.zip

The following command is sufficient to trigger the bug:
# identify graph.svg

# convert --version
Version: ImageMagick 6.4.5 2009-06-04 Q16 OpenMP http://www.imagemagick.org

I have also tested some other versions of ImageMagick, and they behave similarly.

Unfortunately I cannot comment on the origin or correctness of the file; it was uploaded to a server which processes SVG files using ImageMagick. However, in the header, I find: Generated by graphviz version 2.25.20091109.0545 (20091109.0545)

The rsvg-convert utility is able to process the file without problems.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: identify hits an infinite loop with some SVG files.

Post by magick »

Try this command:
  • convert -density 10 graph.svg graph.png
When we try rsvg-convert, version 2.26, it returns nothing (e.g. no rendered image, no exception message).
matheweis

Re: identify hits an infinite loop with some SVG files.

Post by matheweis »

magick wrote: When we try rsvg-convert, version 2.26, it returns nothing (e.g. no rendered image, no exception message).
This is interesting; I am able to get a file from rsvg-convert ( http://www.eisbox.net/tmp/graph.png )

I used the following:
# time rsvg-convert graph.svg -w 6000 -f png -o graph.png
real 0m39.167s
user 0m27.346s
sys 0m5.932s

# rsvg-convert --version
rsvg-convert version 2.26.0

It's an unmodified version from the standard Ubuntu packages
magick wrote: Try this command:
  • convert -density 10 graph.svg graph.png
This helps somewhat; the file in /tmp/ is now only 4.9 Mb instead of several Gb, however there still seems to be some performance issue:

# time convert -density 10 graph.svg graph.png
^C (I stop it as graph.png is 0 bytes and it doesn't seem to be getting anywhere)
real 4m16.998s
user 1m29.734s
sys 2m23.501s

Ultimately, since rsvg-convert is working for me, the conversion is not much of a problem, but I would still like to use identify to get the information about the SVG file's native resolution. Unfortunately, identify seems to be hampered by the same problem as convert.

Is there any way to get identify to simply provide the dimensions and native dpi without all the processing it seems to be wanting to do?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: identify hits an infinite loop with some SVG files.

Post by magick »

We have a patch in ImageMagick 6.5.7-10 Beta (available sometime tomorrow) to return the image metadata quickly for the identify command as you requested. Thanks.
Post Reply