Using RSVG to convert svg with non-local image

痴心易碎 提交于 2019-12-11 03:26:55

问题


I've got an SVG image as follows that I'm trying to convert to a PNG:

<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink">
  <image x="0" y="0" width="158" height="158"
     xlink:href="http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png" />
</svg>

This was working on Ubuntu 10.04, but now on 12.04 it doesn't. The reason appears to be that RSVG now won't load any image URL that doesn't have a relative path.

That's not an option here - my website generates the SVG (so I know it's safe) but it requires that the images are loaded in via HTTP.

The image displays fine in Chrome, but not in Imagemagick, Gimp, or (strangely) Inkscape.

If it helps I'm using Imagemagick via PHP, but RSVG is the delegate for SVG conversion here.

Does anyone have any ideas for how to get around this, short of recompiling librsvg?

I've tried the suggestions at ImageMagick (RSVG) won't import images in SVG and it looks suspiciously like it's this problem: rsvg doesn't render linked images


I found the code that's responsible here: https://git.gnome.org/browse/librsvg/tree/rsvg-base.c#n2169

I could be wrong, but it seems like they've disabled loads from other URLs, without any way to re-enable it short of a recompile?

来源:https://stackoverflow.com/questions/26364748/using-rsvg-to-convert-svg-with-non-local-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!