func NewImageGenerator(options Options) (*ImageGenerator, error) {
	if options.Foreground.A == 0 {
		options.Foreground = color.RGBA{0x96, 0x96, 0x96, 0xff}
	}
	if options.Background.A == 0 {
		options.Background = color.RGBA{0xcc, 0xcc, 0xcc, 0xff}
	}
	if options.MarginRatio < 0 {
		options.MarginRatio = 0.2
	}
	var ttf []byte
	if len(options.TTF) > 0 {
		ttf = options.TTF
	} else if options.TTFPath != "" {
		var err error
		ttf, err = ioutil.ReadFile(options.TTFPath)
		if err != nil {
			return nil, err
		}
	} else {
		return nil, ErrMissingFontOption
	}
	f, err := freetype.ParseFont(ttf)
	if err != nil {
		return nil, err
	}
	return &ImageGenerator{
		font:    f,
		options: options,
	}, nil
}
NewImageGenerator returns a new ImageGenerator
package sticker
import (
	"errors"
	"image"
	"image/color"
	"image/draw"
	"io/ioutil"
	"github.com/disintegration/imaging"
	"github.com/golang/freetype"
	"github.com/golang/freetype/truetype"
	"golang.org/x/image/font"
)
const (
	dpi         = 72.00
	maxFontSize = 512.00
)
type ImageGenerator struct {
	options Options
	font    *truetype.Font
}
type Options struct {
	TTFPath         string
	TTF             []byte
	Foreground      color.RGBA
	Background      color.RGBA
	BackgroundImage image.Image
	MarginRatio     float64
}
var (
	ErrInvalidDimensions = errors.New("values for width or height must be positive")
	ErrMissingFontOption = errors.New("no font option specified")
)