ImageMagick (RSVG) won't import images in SVG

你说的曾经没有我的故事 提交于 2019-12-01 02:31:16

问题


I'me trying to use ImageMagick to convert SVG files to PNG.

The SVG file is as follows:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
    <image xlink:href="picture.jpg" width="200" height="200"/>
</svg>

No matter what method I use the final result doesn't include the image. Other SVG elements have rendered correctly.

I've tried:

convert test.svg test.png
rsvg-convert -o test.png test.svg

I've tried changing the image path to use file:///, absolute paths, remote urls, and url encoded variations of each. I've also formatted my file with and without a doctype.

I'm using librsvg 2.36.3 and ImageMagick 6.8.0-10 I have been able to use phantomjs to convert them but it seems like overkill for this one task.

Please help!


回答1:


For me, installing gtk3 (or probably more specifically "shared-mime-info" helped. (and re-installing rsvg afterwards AND using absolute "file:///" uri for href AND having image file in same directory as svg file)

More info (I'm still confused what exactly is going on):

  • I think the problem is not with rsvg directly, but with gdk-pixbuf(2) library

  • I found the place in the code where gdk-pixbuf is used to load the image. I confirmed (using printf debuggin) that it doesn't throw an error (seems to load pixbuf just fine) even if the uri in the href does not point to a file.

  • the gtk3 dependency should only be necessary for rsvg-view-3 tool, not for rsvg, but it seems to be (or one of the dependencies that got pulled in when I installed gtk3)

  • It still works even after uninstalling gtk3. It even still works after uninstalling gtk3, then rebuilding rsvg (./configure detects: "gtk3: no"), so I figure it must have to do with one of the dependencies that got pulled when I installed gtk3:

  • atk-2.10.0-1-i686

  • hicolor-icon-theme-0.12-2-any
  • gtk-update-icon-cache-2.24.22-1-i686
  • libtasn1-3.3-2-i686
  • p11-kit-0.20.1-1-i686
  • gnutls-3.2.5-1-i686
  • libcups-1.7.0-1-i686
  • libxinerama-1.1.3-2-i686
  • shared-mime-info-1.2-1-i686
  • libgusb-0.1.6-1-i686
  • nspr-4.10.1-2-i686
  • js-17.0.0-1-i686
  • polkit-0.112-1-i686
  • shared-color-profiles-0.1.5-1-any
  • dconf-0.18.0-1-i686
  • colord-1.0.2-2-i686
  • recordproto-1.14.2-1-any
  • libxtst-1.2.2-1-i686
  • at-spi2-core-2.10.1-1-i686
  • at-spi2-atk-2.10.0-1-i686
  • xkeyboard-config-2.10.1-1-any
  • libxkbcommon-0.3.1-1-i686

(I'm leaving these here in case it's not the lib I identified in the end)

So I tried removing these deps in groups and rebuilding and testing in between. Turns out the one making it work is...

* shared-mime-info



来源:https://stackoverflow.com/questions/16702889/imagemagick-rsvg-wont-import-images-in-svg

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