Problems rendering/converting SVGs with embedded images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
pfriedl
Posts: 12
Joined: 2015-04-22T10:00:38-07:00
Authentication code: 6789

Problems rendering/converting SVGs with embedded images

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

Re: Problems rendering/converting SVGs with embedded images

Post by snibgo »

I know nothing about IMagick.

Why isn't Inkscape an option? It processes both your SVG files with no problem.
snibgo's IM pages: im.snibgo.com
pfriedl
Posts: 12
Joined: 2015-04-22T10:00:38-07:00
Authentication code: 6789

Re: Problems rendering/converting SVGs with embedded images

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

Re: Problems rendering/converting SVGs with embedded images

Post 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.
pfriedl
Posts: 12
Joined: 2015-04-22T10:00:38-07:00
Authentication code: 6789

Re: Problems rendering/converting SVGs with embedded images

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