Page 1 of 1

Empty SVG nodes non-deterministically cause convert to hang

Posted: 2014-07-09T22:00:50-07:00
by jestelle
If I run the following:
convert test.svg -colors 5 -depth 8 -format "%c" histogram:info:
most of the time it completes perfectly, but about 20% of the time, it will hang indefinitely.

Here is the file I'm testing with
https://drive.google.com/file/d/0BwTtDg ... sp=sharing

This is the version of ImageMagick I'm running
Version: ImageMagick 6.8.9-1 Q16 x86_64 2014-05-12 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib freetype jng jpeg ltdl lzma png xml zlib

This is on OS X 10.9.3

The problem seems to be with paths or shapes that don't actually render anything, like:
<g>
<path d="M20.4,18"/>
</g>
and
<g>
<polygon points="24,15 24,15 24,15 "/>
</g>

Removing things like this fixes it.

Here's the fixed file that doesn't have any problem:
https://drive.google.com/file/d/0BwTtDg ... sp=sharing

Is there an underlying ImageMagick bug that can be fixed?

Re: Empty SVG nodes non-deterministically cause convert to h

Posted: 2014-07-09T22:26:23-07:00
by fmw42
I don't know much about SVG files, but what delegate are you using to read the svg file. see what is reported for SVG from

convert -list format

Does it say XML, RSVG or Inkscape?

If XML (IM internal MSVG), then try installing RSVG or Inkscape and recompile IM.

Your file and command works fine for me on IM 6.8.9.5 Q16 Mac OSX. I am using RSVG


SVG SVG rw+ Scalable Vector Graphics (RSVG 2.40.2)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (RSVG 2.40.2)

Re: Empty SVG nodes non-deterministically cause convert to h

Posted: 2014-07-10T20:06:09-07:00
by snibgo
With IM 6.8.9-0 on Windows 8.1, using RSVG or MSVG or Inkscape as delegates, your file converts for me without problems.

Re: Empty SVG nodes non-deterministically cause convert to h

Posted: 2014-07-11T08:27:16-07:00
by jestelle
Thanks guys.

~ > convert -list format | grep SVG
MSVG SVG rw+ ImageMagick's own SVG internal renderer
SVG SVG rw+ Scalable Vector Graphics (XML 2.9.0)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (XML 2.9.0)

Best,
Josh Estelle

Re: Empty SVG nodes non-deterministically cause convert to h

Posted: 2014-07-11T08:59:21-07:00
by fmw42
XML, I believe means you are using the IM internal MSVG, which is not as full featured as the others. I would suggest you install RSVG or Inkscape and then compile IM again and try again.

Re: Empty SVG nodes non-deterministically cause convert to h

Posted: 2014-07-11T09:26:47-07:00
by jestelle
That's a great suggestion for a workaround, but isn't there an underlying bug here?

In particular, if it was constantly failing, that would be indicative of a lack of support causing a problem. But most of the time it works, it just gets stuck in some busy-loop sometimes.

Re: Empty SVG nodes non-deterministically cause convert to h

Posted: 2014-07-11T09:32:32-07:00
by fmw42
Your case is likely one in which there only some svg files that contain certain tags or coordinates that are defined by more advanced features than in MSVG. So MSVG fails for those, but likely RSVG or Inkscape will work. This is just my guess at what is happening. Or perhaps there was a bug in the version of IM that you are using that was fixed in some later release. Snibgo said it worked fine for him with all 3 SVG renderers. That would seem to indicate it might be in your install. I can only tell you it worked fine for me using RSVG.

Have you tried re-installing IM?

Does it fail every time you run that SVG file or only sometimes?

It is doubtful that it could be fixed if the IM developers cannot make it fail. The will have to test it with MSVG. What platform are you on?