本文介绍了使用librsvg / rsvg通过ImageMagick转换SVG图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题在这里有几个答案版本(像这样:),但实际上我找不到真正的解决方案来解决我的确切问题。我的问题是:我有一个特定的SVG文件(我将生成更多),SVG> PNG转换器进程内的ImageMagick无法完美转换。所以我需要将其更改为 librsvg ,因为它确实如此,我测试了这两行不同的结果:

I know this question has several answered version here (like this: ImageMagick convert SVG to PNG not working with RSVG enabled ), but actually I can't find a real solution to my exact problem. My problem is: I have a specific SVG file (and I will generate more) that ImageMagick inside SVG>PNG convertor process doesn't convert perfectly. So I need to change it to librsvg, because it does, I tested these 2 lines with different result:

    convert test.svg test.png  // ( img: http://tinyurl.com/px2lw3v )
    rsvg-convert test.svg -o test.png // ( img: http://tinyurl.com/lreu6sk )

我安装了HomeBrew。如下所述:我使用此代码安装ImageMagick brew install imagemagick --use-rsvg 。我意识到它没有安装 librsvg 所以我需要卸载它并重新安装如下: brew重新安装imagemagick --with-libsrvg librsvg --use-rsvg :这个已安装的imagemagick& librsvg一起到我的mac。但是没有连接它们: convert -list format | grep SVG 结果为:

I installed HomeBrew. As described here: ImageMagick convert SVG to PNG not working with RSVG enabled I used this code to install ImageMagick brew install imagemagick --use-rsvg. I realized that it not installs librsvg so I needed to uninstall it and reinstall like this: brew reinstall imagemagick --with-libsrvg librsvg --use-rsvg : this installed imagemagick & librsvg together to my mac. BUT doesn't connected them: convert -list format | grep SVG resulted as:

 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)


虽然这个: convert -list delegate | grep svg 结果为:

    svg =>          "rsvg-convert" -o "%o" "%i"

我安装了&卸载&重新安装了几次&方式,但没有改变,脚本转换test.svg test.png 没有librsvg这样做。我在/usr/local/Cellar/imagemagick/6.8.9-1/lib/ImageMagick/config-Q16/configure.xml中添加了带标签的行,但没有任何进展。我不知道该怎么做以及如何连接ImageMagick并强制使用不同的库来进行 convert test.svg test.png

I installed & uninstalled & reinstalled them several times & ways but nothing changed and the script convert test.svg test.png do it's way without librsvg. I added lines to /usr/local/Cellar/imagemagick/6.8.9-1/lib/ImageMagick/config-Q16/configure.xml with tags but nothing progressed. I don't know what to do and how to connect ImageMagick and force to use different library for convert test.svg test.png.

感谢您的帮助。

更多信息:

    $ which convert
    /usr/local/bin/convert

    $ convert -version
    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

    $ otool -L $(which convert)
    /usr/local/bin/convert:
        /usr/local/Cellar/imagemagick/6.8.9-1/lib/libMagickCore-6.Q16.2.dylib (compatibility version 3.0.0, current version 3.0.0)
        /usr/local/Cellar/imagemagick/6.8.9-1/lib/libMagickWand-6.Q16.2.dylib (compatibility version 3.0.0, current version 3.0.0)
        /usr/local/lib/libfreetype.6.dylib (compatibility version 18.0.0, current version 18.2.0)
        /usr/lib/liblzma.5.dylib (compatibility version 6.0.0, current version 6.3.0)
        /usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
        /usr/local/lib/libltdl.7.dylib (compatibility version 11.0.0, current version 11.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

    $ which rsvg-convert
    /usr/local/bin/rsvg-convert

    $ otool -L $(which rsvg-convert)
    /usr/local/bin/rsvg-convert:
        /usr/local/Cellar/librsvg/2.36.3/lib/librsvg-2.2.dylib (compatibility version 39.0.0, current version 39.3.0)
        /usr/local/lib/libgdk_pixbuf-2.0.0.dylib (compatibility version 3001.0.0, current version 3001.8.0)
        /usr/local/lib/libgio-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
        /usr/local/lib/libpangocairo-1.0.0.dylib (compatibility version 3601.0.0, current version 3601.5.0)
        /usr/local/lib/libpango-1.0.0.dylib (compatibility version 3601.0.0, current version 3601.5.0)
        /usr/local/lib/libgobject-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
        /usr/local/lib/libcairo.2.dylib (compatibility version 11203.0.0, current version 11203.16.0)
        /usr/local/lib/libpng16.16.dylib (compatibility version 29.0.0, current version 29.0.0)
        /usr/local/lib/libcroco-0.6.3.dylib (compatibility version 4.0.0, current version 4.1.0)
        /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
        /usr/local/lib/libgthread-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
        /usr/local/lib/libglib-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
        /usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.2.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)




  • ImageMagick 6.6.9-1

  • Mac OS X 10.9.4

  • 推荐答案

    (只需在Zoltan的答案中添加更多上下文)

    (Just adding more context to Zoltan's answer)

    使用 brew info imagemagick 查看安装时的可用选项。

    Use brew info imagemagick to see available options when installing it.

    --with-librsvg
        Build with librsvg support
    

    这篇关于使用librsvg / rsvg通过ImageMagick转换SVG图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 21:19