Use librsvg / rsvg to convert SVG images with ImageMagick
Asked Answered
F

4

17

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 )

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)

while this: convert -list delegate | grep svg resulted as:

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

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.

Thank you for your help.

More information:

    $ 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
Farny answered 1/7, 2014 at 14:49 Comment(1)
If you install Inkscape on your system, ImageMagick will use it automatically. It does not need to be installed as a delegate. It is usually better than RSVG.Servile
E
6

(Just adding more context to Zoltan's answer)

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

--with-librsvg
    Build with librsvg support
Esdraelon answered 17/12, 2014 at 11:22 Comment(1)
homebrew option --with-librsvg no longer supported. I get errorAlage
D
16

I tried and my solution is on Mac:

  1. run brew doctor and brew update
  2. use simply brew reinstall imagemagick --with-librsvg // - you may misspelled!
  3. try it. it should work!

Is it work?

Diantha answered 16/7, 2014 at 22:43 Comment(2)
hi zoltan can you look at this related question? your post helped me successfully get it working locally but there are text nuances on server that preclude success right now #26790232Ironbound
This answer appears to be outdated- current homebrew gives error Error: invalid option: --with-librsvgArminius
M
9

If you want to use Homebrew to install imagemagick with svg support, you need to use an older version. They removed options from the installation process early 2019.

    brew install https://github.com/Homebrew/homebrew-core/raw/46a2ef7c9f0380b8e19f8dfe37270caa27581353/Formula/imagemagick.rb --with-librsvg
Multiflorous answered 11/4, 2019 at 16:43 Comment(1)
Or, compile from source since "GraphicsMagick may be compiled from source code for virtually any modern Unix system (including Linux and MacOS X)"Confer
E
6

(Just adding more context to Zoltan's answer)

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

--with-librsvg
    Build with librsvg support
Esdraelon answered 17/12, 2014 at 11:22 Comment(1)
homebrew option --with-librsvg no longer supported. I get errorAlage
C
3

The --with-librsvg option is no longer supported. Instead librsvg is its own package now and will install the rsvg-convert command.

brew install librsvg

For reference https://formulae.brew.sh/formula/librsvg#default

Careycarfare answered 5/11, 2023 at 19:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.