svg2png

package module
v0.0.0-...-6ba87c8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2020 License: Unlicense Imports: 12 Imported by: 8 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

svg2png

Using chrome headless to convert svg to png

GoDoc

Example:
package main

import (
	"os/exec"

	"github.com/canhlinh/svg2png"
	"github.com/sirupsen/logrus"
)

func main() {
	chrome := svg2png.NewChrome().SetHeight(600).SetWith(600)
	filepath := "Soccerball_mask_transparent_background.png"
	if err := chrome.Screenshoot("https://upload.wikimedia.org/wikipedia/commons/8/84/Example.svg", filepath); err != nil {
		logrus.Panic(err)
	}

	exec.Command("open", filepath).Run()
}

Documentation

Index

Constants

View Source
const (
	// MinChromeVersion minimize version allowed chrome headless
	MinChromeVersion = "59"
)

Variables

View Source
var (

	// DefaultChromPaths posible chrome paths
	DefaultChromPaths = []string{
		"/usr/bin/chromium-browser",
		"/usr/bin/chromium",
		"/usr/bin/google-chrome-stable",
		"/usr/bin/google-chrome",
		"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
		"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
		"/Applications/Chromium.app/Contents/MacOS/Chromium",
		"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"}

	// DefaultChromeHeight default height value of chrome brower
	DefaultChromeHeight = 1200
	// DefaultChromeWidth default width value of chrome brower
	DefaultChromeWidth = 720
	// DefaultTimeout default timeout
	DefaultTimeout = 3 * time.Second
)

Functions

This section is empty.

Types

type Chrome

type Chrome struct {
	// contains filtered or unexported fields
}

Chrome contains information about a Google Chrome instance, with methods to run on it.

func NewChrome

func NewChrome() *Chrome

NewChrome intalizes new Chrome

func (Chrome) Resolution

func (chrome Chrome) Resolution() string

Resolution returns chrome's resolution

func (Chrome) Screenshoot

func (chrome Chrome) Screenshoot(websiteURL string, destination string) error

Screenshoot takes a screenshot by the given website url

func (*Chrome) SetHeight

func (chrome *Chrome) SetHeight(h int) *Chrome

SetHeight sets chrome's width

func (*Chrome) SetTimeout

func (chrome *Chrome) SetTimeout(timeout time.Duration) *Chrome

SetTimeout set chrome's timeout

func (*Chrome) SetWith

func (chrome *Chrome) SetWith(w int) *Chrome

SetWith sets chrome's width

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址