10 June 2012

RSVG-Convert SVG image conversion tool

LibRSVG is probably one of well known svg library (other is Batik), the library use libcairo for pdf,ps and svg backend. This is a convenient static build of RSVG-Convert (part of librsvg 2.34.2) compiled with MinGW. I made this since originally the executable would dragged many dependencies.

The command line also used by ImageMagick through delegates although being deprecated (the rsvg wrapper), currently rsvg-convert.exe support png, ps, pdf and xml output but not jpg.

use "rsvg-convert --help" to see its command options, notice that the default output is stdout so be sure to specify file output.
version 2.40.5: rsvg-convert.exe  (last update: 17-10-2014 news: support svgz input and eps output)
version 2.40.1: rsvg-convert.exe  (last update: 07-03-2014)
version 2.36.4: rsvg-convert.exe

31 comments:

  1. Hello,
    i've got some warning using your tool :
    (rsvg-convert.exe:12340): Pango-WARNING **: error opening config file 'E:/msys/MSYS/local/rsvg/etc/pango\pangorc': Permission denied

    and some error about fonts :
    (rsvg-convert.exe:12340): Pango-WARNING **: couldn't load font "MS Shell Dlg Not-Rotated 2.439453125", falling back to "Sans Not-Rotated 2.439453125", expect ugly output.

    (rsvg-convert.exe:12340): Pango-WARNING **: couldn't load font "MS Shell Dlg Not-Rotated 2.7998046875", falling back to "Sans Not-Rotated 2.7998046875", expect ugly output.

    (rsvg-convert.exe:12340): Pango-WARNING **: couldn't load font "MS Shell Dlg Not-Rotated 2.9677734375", falling back to "Sans Not-Rotated 2.9677734375", expect ugly output.

    (rsvg-convert.exe:12340): Pango-WARNING **: couldn't load font "MS Shell Dlg Not-Rotated 2.8154296875", falling back to "Sans Not-Rotated 2.8154296875", expect ugly output.

    (rsvg-convert.exe:12340): Pango-WARNING **: couldn't load font "MS Shell Dlg Not-Rotated 2.8798828125", falling back to "Sans Not-Rotated 2.8798828125", expect ugly output.

    Anyway, your tool works well, thank you !
    Thierry

    ReplyDelete
    Replies
    1. the first error message are harmless it's not needed for windows, the warnings also generally can be ignored. But if you concerned (your text output not looking good). Try download this http://osspack32.googlecode.com/files/fontconfig.7z extract it to where you have rsvg and execute fc-cache (it will cache your whole windows's fonts), it may takes time to finished. Then try again rsvg

      note: I'm not sure whether my previous build has fontconfig support, so I updated it (version 2.36.1) as the same link in original post. try redownload

      Delete
  2. Hello,
    your update remove the first error, thank you !
    For the others, the text output seems ok, so I keep the actual fonts, but in case of, I will apply your solution.
    Regards
    Thierry

    ReplyDelete
  3. Hi TumaGonx Zakkum,

    Thank you very much for this static build. I wish you could keep it up to date.

    ReplyDelete
  4. Really useful, thanks! I'm having incompatibility issues between MediaWiki (librsvg) and Inkscape, and this allows me to test out my changes without needing to keep re-uploading duff images to MediaWiki.

    ReplyDelete
    Replies
    1. maybe you just need rsvg-viewer? http://osspack32.googlecode.com/files/rsvg-view-3.exe
      drag n drop svg on it or associate it with svg

      Delete
    2. Interesting, thanks. Only snag is, the window doesn't open to the size of the document, and twice within the last few minutes I've crashed the program simply enlarging the size of the window using the size grip. (Windows 8 Pro)

      Certainly easier than repeatedly saving to PNG though :)

      (PS your OpenID system doesn't work. "Your OpenID credentials could not be verified. Makes no effort to actually check; it just can't be bothered, and gives up.)

      Delete
    3. Have you downloaded the latest (same link)? the not open to size issue have been fixed AFAIK.

      About the openID, i'm not sure if I can do anything about it, I think it's part of blogspot? Sorry about it

      Delete
    4. Ah yes, on some svgs there is 20-30px missing from the window. Can't confirm about windows 8 crash though

      Delete
    5. Same crash in XP SP3 32-bit:

      http://telcontar.net/store/hosted/bugs/rsvg-view_crash.png

      Randomly crashes when enlarging the window, as you can see from the above. Might be image dependent. You can contact me via my website if you want me to try test builds etc.

      Delete
    6. Maybe because I'm not enabling "Show windows contents while dragging" desktop setting. But still, this is a bug (for GTK-3)

      Delete
  5. Thanks. Very useful.

    ReplyDelete
  6. thank you very much! long ago I was looking for svg to png converter, it is best to have a few kb

    ReplyDelete
  7. Hi,

    I've downloaded the exe. When I'm running it, it opens the win cmd and do nothing.

    Any clue?

    ReplyDelete
    Replies
    1. 1. open the commandline "cmd"
      2. CD to the DIR of the EXE
      3. try something like this or what ever you wanted to do:

      rsvg-convert.exe -a -w 500 -f svg INPUT.SVG -o OUTPUT.SVG

      Delete
  8. Hi,

    I tried to get the help as you have mentioned. But i get the following error

    D:\ImageMagick>rsvg-convert.exe -help
    Missing argument for -h

    ReplyDelete
    Replies
    1. notice the commandline use two dash "--help"

      Delete
    2. Thanks for the quick reply.. works like a charm.

      Delete
  9. Awesome tool..

    By the way, I can't convert an eps file using this right?
    when I tried, I am getting
    Error reading SVG:Error domain 1 code 4 on line 1 column 1 of file:///D://eps/Template2.eps: Document is empty

    It clearly says, Error reading SVG. :)

    ReplyDelete
  10. Hi,

    Does this support embedding external images?

    I have an svg file with 'image' tag which was not rendered by this program. All I see in the output is text.

    ReplyDelete
  11. Haven't tried that myself, maybe this help http://stackoverflow.com/questions/2961624/rsvg-doesnt-render-linked-images

    ReplyDelete
  12. I've begun to use rsvg-convert for text-based SVG, and it's wonderful.

    However, my svg has an image embedded in it using the form of:


    image
    height = "100"
    width = "100"
    x = "455"
    xlink:href = "data:;base64,{imageDataInBase64}"
    y = "90"

    My image is not getting into the PDF. Is rsvg-convert unable to process images?

    Help!

    ReplyDelete
  13. Hi,
    Your rasterizing utility is excellent.

    However, I have observed that applying various desired dpi densities in command-line parameters, like this:
    rsvg-convert.exe -d 300 -p 300
    rsvg-convert.exe -d 100 -p 100
    rsvg-convert.exe -d 600 -p 600
    or like this
    rsvg-convert.exe --dpi-x 600 --dpi-y 600
    or even without specifying density which should default to 90:
    rsvg-convert.exe

    HAS NO EFFECT.

    Moreover, the effect is (what I'm verifying by examining obtained raster image geometry comparing with SVG contents) as in all cases, density of 300 dpi has been used.

    Obtained PNG files with various settings are binary identical.

    After some experiments, I've observed that the only method to control effective resolution, is to pass width and height parameters recalculated accordingly. For example, to obtain 600 dpi, it is necessary to pass width and height multiplied twice.

    In my application, I have to keep control over raster image geometry so as to have its content in sync with vectors displayed above, so proper behavior in this matter is for me important.

    May be there is something wrong in the way I pass density parameters?

    Could you explain this behavior, please?

    ReplyDelete
    Replies
    1. Hi Krzysztof,

      Just to clarify I'm not write this app, I just build unofficial win32 executable like all other stuff in this blog.

      I can't help you or confirm this bug at the moment but if you're sure about it, you can filled bugreport to the developer here https://bugzilla.gnome.org/browse.cgi?product=librsvg. They're the right person to talk about it :)

      Delete
    2. Thank you for fast response.
      I've found following issue at bugzilla:

      There is no difference between different DPIs
      https://bugzilla.gnome.org/show_bug.cgi?id=681127

      that seems to point to the same problem, but with no answer.
      I'll try to post my own one.

      Regards,

      Delete
  14. This comment has been removed by the author.

    ReplyDelete
  15. Thx for making this wonderful conversion tool. But I have 2 major issues. 1) When converting to PDF, the opacity value in the or elements are ignored. 2) The conversion fails to apply bold or italic styles for some font such as WenQuanYi Zen Hei (文泉驛正黑).

    ReplyDelete
    Replies
    1. Thanks, librsvg 2.40 released few days ago, will see if I can do something about the bug when updating the win32 binary.

      Delete
    2. Sorry my previous comment was incomplete. For the PDF conversion, I mean the opacity property in "g" and "text" elements are ignored. This isn't the problem when converting to PNG.

      For the bold and italic font, your conversion tool reports that it can't find "WenQuanYi Zen Hei bold" or "WenQuanYi Zen Hei italic", but this problem doesn't exist in Wikimedia which uses the same typeface.

      Delete
  16. Hi, thanks for this. I have the same problem with failure to open 'E:/msys/MSYS/local/rsvg/etc/pango\pangorc': etc but in my case, since E: is my optical drive, I get a while bunch of windows warning dialogs saying "there is no disk in the drive please insert a disk". Not usable in that case. Thanks.

    ReplyDelete
  17. One bug about converting to PDF: it is unable to apply mask (http://www.w3.org/TR/SVG11/masking.html#Masking), but the mask is present while converting to PNG.

    ReplyDelete