Empty SVG nodes non-deterministically cause convert to hang

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
jestelle
Posts: 3
Joined: 2014-07-09T21:40:57-07:00
Authentication code: 6789

Empty SVG nodes non-deterministically cause convert to hang

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
jestelle
Posts: 3
Joined: 2014-07-09T21:40:57-07:00
Authentication code: 6789

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
jestelle
Posts: 3
Joined: 2014-07-09T21:40:57-07:00
Authentication code: 6789

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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?
Post Reply