Go Tool to convert svg to png/jpg

3,259 views
Skip to first unread message

will

unread,
Mar 10, 2015, 2:35:51 AM3/10/15
to golan...@googlegroups.com
Hi Gophers,

Is there a Golang based tool (or library) tool to convert svg to png or jpg?

regards,

Will

maithri...@gmail.com

unread,
Jan 31, 2020, 8:45:36 PM1/31/20
to golang-nuts
I'm looking for one too but can't find anything online either..

robert engels

unread,
Jan 31, 2020, 9:04:11 PM1/31/20
to maithri...@gmail.com, golang-nuts
There is no cross-platform graphics library included in Go.

Most likely you’ll need a C binding to Qt or similar to perform the rasterization.

You might be able to put one together using something like https://github.com/hajimehoshi/ebiten


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d03ad514-1e56-42a3-b7c6-798346a76ca1%40googlegroups.com.

Michael Jones

unread,
Jan 31, 2020, 9:55:00 PM1/31/20
to robert engels, maithri...@gmail.com, golang-nuts
Just to be clear: PNG is a description of pixel values comprising an image (RGBa, RGBa, RGBa, ...), SVG is a program for creating an image (set color to blue, draw a circle, change to red, draw a line, ...). Going from SVG (scalable vector graphics) to pixels is to render an image by executing the simple program of graphical operation codes. (As said above)

Solutions depending on situation: most every browser has code to rasterize SVG. Can you invoke one to produce your image? There are numerous free tools to do the same--can you bundle one of those and invoke it as an external program? Cairo can do it. (these are in addition to what you really seem to want, which is a fully Go SVG -> PNG renderer.)

Good luck in your project,
michael



--
Michael T. Jones
michae...@gmail.com

Randall O'Reilly

unread,
Feb 1, 2020, 1:21:39 AM2/1/20
to Michael Jones, robert engels, maithri...@gmail.com, golang-nuts
Here’s some partial SVG renderers in Go:

* https://github.com/srwiley/oksvg
* https://github.com/goki/gi (uses srwiley’s rasterx rasteriser, has separate SVG parsing / painting impl).

Cheers,
- Randy
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CALoEmQw_8%3D3AkkrmZNG9Xrzq37TaauFF77wJUGjkp-Mx3%3DrUPQ%40mail.gmail.com.

robert engels

unread,
Feb 1, 2020, 1:47:08 AM2/1/20
to Randall O'Reilly, Michael Jones, maithri...@gmail.com, golang-nuts
That rasterx is pretty sweet. Should be pretty easy to create an SVG to PNG module using that.
Reply all
Reply to author
Forward
0 new messages