Categorygithub.com/secr3t/text2img
repositorypackage
0.0.2
Repository: https://github.com/secr3t/text2img.git
Documentation: pkg.go.dev

# README

text2img

GoDoc License

package text2img lets you generate an image from a text. It's especially useful to generate OG images.

Example

Installation

Binary

If you use text2img from your command line, install the binary from releases.

Or use go get:

go get github.com/Iwark/text2img/cmd/text2img

Go code

If you use text2img from your go code, install the package by go get.

$ go get github.com/Iwark/text2img

Usage

bgimgEx

(The Go gopher was designed by Renée French.)

Go code

You can use this package as follows:

package main

import (
  "image/jpeg"
  "os"

  "github.com/Iwark/text2img"
)

func main() {
  path := "fonts/font.ttf"
  d, err := text2img.NewDrawer(text2img.Params{
    FontPath: path,
  })
  checkError(err)

  img, err := d.Draw("text2img generates the image from a text")
  checkError(err)

  file, err := os.Create("test.jpg")
  checkError(err)
  defer file.Close()

  err = jpeg.Encode(file, img, &jpeg.Options{Quality: 100})
  checkError(err)
}

More usage can be found at the godoc.

License

This package is released under the MIT License.