Page 1 of 1

Problems rendering/converting SVGs with embedded images

Posted: 2015-09-28T13:33:38-07:00
by pfriedl
Hi all. I've been looking for some kind of answer for this, and simply haven't found it yet.

I'm using ImageMagick 6.9, and I've got an app that should open SVGs, resize and build a composite image, then export to PNG. I have two problems:
  • ImageMagick doesn't seem to handle the <g> element in SVGs. I've tested the same SVG with embeded images, and the first where the image is by itself in the SVG converted with no issues.

    The second SVG with the same image, but wrapped in a <g> element resulted in a blank output.
  • SVGs with large (10Mb) embedded images. I'm using PHP, so I'm processing via IMagick. I get this error when trying to open an SVG with large images:

    Code: Select all

    'ImagickException' with message 'internal error: Huge input lookup `No such file or directory` @ error/svg.c/SVGError/2639'
    I can test my script with the same PNG that was embedded in the SVG and there is no issue with opening a 10Mb file.
This is a big deal, as I have GOT to process these SVGs properly - Inkscape or other desktop software to preprocess is not an option. Are there any workarounds?

Here are links to the test SVGs...
SVG that renders fine: http://brainboxinteractive.com/test1.svg
SVG with image wrapped in a <g> element: http://brainboxinteractive.com/test2.svg
Huge SVG: http://brainboxinteractive.com/test.svg

Thanks for any help!

Re: Problems rendering/converting SVGs with embedded images

Posted: 2015-09-28T14:07:22-07:00
by snibgo
I know nothing about IMagick.

Why isn't Inkscape an option? It processes both your SVG files with no problem.

Re: Problems rendering/converting SVGs with embedded images

Posted: 2015-09-28T14:10:36-07:00
by pfriedl
Can inkscape be called from php and run on the server? If so, I'd be very interested in seeing if I could use that as an option.

Re: Problems rendering/converting SVGs with embedded images

Posted: 2015-09-28T14:40:11-07:00
by fmw42
I am not an SVG expert. But have you tried compiling IM with RSVG or Inkscape? The internal MSVG renderer is known to have many limitations. RSVG may work fine, but Inkscape seems to be the best of the three.

Install the RSVG delegate, then use --with-rsvg in your ./configure.

See also http://www.imagemagick.org/script/advan ... lation.php

If I am not mistaken, if you have Inkscape installed, I believe that IM will use it automatically, if rsvg is not enabled.

Re: Problems rendering/converting SVGs with embedded images

Posted: 2015-09-28T14:51:35-07:00
by pfriedl
Thanks for the help so far guys, I'm getting closer!

I installed the inkscape RPM via WHM's installer, and now IM will successfully convert SVGs that have embedded images and other elements wrapped in <g> tags.

One down, one to go. Do you have any clues on being able to open the really big files? That's still a blocker.

Thanks again for the help!