drf21989 2013-06-14 09:22
浏览 193
已采纳

将SVG转换为图像

How do I convert an svg file to an image using Go ?

I found the amazing svgo library and would like to use it to generate a custom set of playing cards. The idea is to store the text and layout of a card in a text file and then read and process it with go. This would be a huge improvement of my current workflow where I use gimp to edit each individual card. The problem is that I need to have an image of the card for printing. Preferably png since the printing script so far only works with that format. But I could easily adapt it to accept jpeg, too.

Unfortunately svgo doesn't seem to offer export functionality. Can you recommend a go library to convert svg to png ?

  • 写回答

2条回答 默认 最新

  • dousi2251 2013-06-15 08:00
    关注

    One possible strategy is to write your SVG to files and invoke an external tool to convert them. For example, ImageMagick and its related GraphicsMagick will both convert SVG to PNG via command-line options. You would need to use the convert verb, possibly within their batch support if you're converting lots of images at once.

    GraphicsMagick has bindings for C and other languages that you could use directly from your Go scripts, although I've not tried this myself.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?