23

How can I convert SVG image to something raster? Are there any native [command-line] tools on OS X that can do that? I am able to open them in Safari or Firefox, but doing "Save as..." only proposes original (.svg) or web-archive formats and no rasterized image format.

3

4 Answers 4

8

You can do this with Inkscape:

/Applications/Inkscape.app/Contents/Resources/script --without-gui --export-png=raster-image.png  source-image.svg

To change output resolution you can set the DPI value:

/Applications/Inkscape.app/Contents/Resources/script --without-gui --export-png=raster-image.png --export-dpi=200  source-image.svg

Here are more command line options.

1
  • inkscape 0.91 current version doesn't seem to display svg images properly, and therefore the conversion to a png is 'correct' as far as this broken inkscape is concerned, but doesn't result in the correct images. YMMV but I would be careful before relying too heavily on inkscape for this purpose. Note that I have used inkscape in exactly this way myself until I've come across an SVG that it breaks on.
    – Phil Ryan
    Mar 24, 2016 at 6:05
13

Try Gapplin. It works for me and creates PNG and JPG files from SVG. Simple and effective.

If you have a lot of SVG files to convert, ImageMagick is probably your best bet (available directly from imagemagick.org or via Homebrew).

5
  • Best I can find after tried imagemagic and qlmanage.
    – wanghq
    Dec 23, 2016 at 1:32
  • Gapplin is easy to use, and it helped me. Thanks for sharing the link.
    – R. Mohan
    Jul 2, 2018 at 8:31
  • 2
    @wanghq I had lousy results with ImageMagick on Mojave. I suspect I didn't set all the flags, etc., but CairoSVG is dirt simple to use. I was able to easily convert SVGs to PDFs that Xcode didn't puke on.
    – Adrian
    Dec 3, 2018 at 2:40
  • 1
    Installation of ImageMagick (via Homebrew) took more than 1 hour.
    – user265684
    May 14, 2019 at 11:58
  • I have an SVG that doesn't render properly when using the online conversion sites like cloudconvert. Gapplin solved the issue. Dec 21, 2022 at 22:11
8

https://cloudconvert.org/svg-to-png - was fastest way for me.
it's not my site.

3
  • 10
    It's not native though...
    – nohillside
    Sep 5, 2014 at 14:00
  • 9
    Absolutely native. Works in any browser and solves the problem. Sure this answer will be useful for somebody.
    – OZ_
    Sep 5, 2014 at 18:53
  • 3
    Different definitions of 'native' here. OP's 'native' refers to a Mac binary application.
    – alexkent
    Jun 18, 2020 at 10:13
2

One (wonky) option would be to render it in Safari and take a screenshot of the result, although that's obviously not a good solution.

Sadly there's little SVG support in OS X so far apart from Safari, Preview.app (the obvious choice for image format conversion) can't render it and I'm not aware of any bundled command line tools that can either.

As for third party command line tools, Homebrew makes Cairo's svg2png as well as the ImageMagick bundle easily available.

Not the answer you're looking for? Browse other questions tagged .