You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/kanrichan/resvg-go

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/kanrichan/resvg-go

v0.0.2-0.20240921102445-6054d719645e
Source
Go
Version published
Created
Source
椛

resvg-go


A SVG renderer written in Go & WASM depended on resvg without CGO

Usage

Render by default

// initialize and don't forget to close!
// worker are not goroutine-safe!
worker, _ := NewDefaultWorker(context.Background())
defer worker.Close()

// render the SVG as a PNG!
png, _ := worker.Render(svg)

Render with options

// initialize and don't forget to close!
// worker are not goroutine-safe!
worker, _ := NewDefaultWorker(context.Background())
defer worker.Close()

// render the SVG as a PNG!
fontdb, _ := worker.NewFontDBDefault()
defer fontdb.Close()
fontdb.LoadFontData(ttf)

pixmap, _ := worker.NewPixmap(512, 512)
defer pixmap.Close()

tree, _ := worker.NewTreeFromData(svg, &Options{})
defer tree.Close()
tree.ConvertText(fontdb)
tree.Render(TransformIdentity(), pixmap)

png, _ := pixmap.EncodePNG()

Thanks

  • resvg - an SVG rendering library written in Rust
  • wazero - the zero dependency WebAssembly runtime for Go developers

FAQs

Package last updated on 21 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts