0

I'm struggling to convert a bunch of images from SVG to PDF/PNG using imagemagick, though I haven't ever had an issue using Imagemagick with other files. It appears that IM either hangs or just takes an excruciatingly long time.

The command I'm using is pretty simple:

convert -background none in.svg out.pdf

Here's version info if thats useful (on OSX, High Sierra):

Version: ImageMagick 6.9.9-26 Q16 x86_64 2018-03-27 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): bzlib djvu fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms ltdl lzma openexr png ps raw tiff webp x xml zlib

The images are the output of a web rendering tool, and an example can be found here (couldn't figure out a better way to share):

https://drive.google.com/open?id=1zypR9KsR4oskvgRQubDAKIVHXlCFmTz9

I've seen other threads which suggest that ImageMagick resulting in slow conversions of images from SVG to other formats can be due to image sizes etc, but these are only ~30kb (output of identify: SVG 978x648 978x648+0+0 16-bit sRGB 26333B 0.000u 0:03.460)

(Oddly, I get no output from identify until I Ctrl-C the process, then it prints).

There must be something 'wrong' with the files, but as far as I can tell they're valid SVGs, the images can be viewed without an issue etc etc. I'm not sure what I'm missing.

Joe Healey
  • 1,232
  • 3
  • 15
  • 34
  • What is notably missing from the Delegates list is `rsvg`. Try to install librsvg, which on my Linux system has no problem rendering your file.. Unfortunately I am not at home in OSX, but maybe [this](https://stackoverflow.com/questions/24513244/use-librsvg-rsvg-to-convert-svg-images-with-imagemagick) is helpfull. – ccprog Jun 07 '18 at 16:22
  • You will get better results by Installing Inkscape so that ImageMagick can use it or install the rsvg delegate so that imagemagick can use it. The ImageMagick internal MSVG/XML renderer is not as good. On my Mac OSX Sierra with RSVG 2.42.2, your command took 1.2 sec with ImageMagick 6.9.9.50 Q16 – fmw42 Jun 07 '18 at 16:41
  • What is *"a long time"* please? – Mark Setchell Jun 07 '18 at 17:34
  • Read: yet to finish. I've watched the command for probably 5 minutes with no progress it seems, but imagemagick never takes that long. Ive even converted 70Mb 4k TIFF files in less time with it. Ill check the libs as you all suggest and report back – Joe Healey Jun 07 '18 at 17:39
  • I think IM 6.9.9.26 may have been a bad release. I tried converting your file with it, though it finished in 2 sec, the pdf could not be opened. You may want to upgrade your IM version, which is at this time 6.9.9.50 or use IM 7. – fmw42 Jun 07 '18 at 22:08
  • Various weird updates. Firstly, I couldnt update IM *.26 to *.50 for some reason (despite force uninstalling everything in brew). I did reinstall with the `rsvg` module and switched to using IM7 however, and this appears to be working now, with the conversion happening in under 2 seconds. The rsvg module still doesn't appear under my *.26 install (it's possible I'm mixing up multiple package managers though). Oddly, the first time IM7 converted the file, it took a while, but every time after that its been under 2 seconds. So, I'm not sure if rsvg under IM6 would solve it, but rsvg/IM7 did. – Joe Healey Jun 08 '18 at 11:48

0 Answers0