wordimg

package module
Version: v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: MIT Imports: 14 Imported by: 0

README

Word Img

Go Reference

This generate a random image from the entered words.

Http

Endpoint

Endpoint to generate image.

https://wordimg-otho5yxlgq-an.a.run.app/wordimg

Query

The size of the image is fixed at 512 * 512.

  • text Text to write to image.
  • size Font size. Supports j${line} as a special format. If you specify 'j1', the font size will fit on one line.
  • color Text color.
  • align Word postion. Default is 'left'. 'left' or 'center'.

CLI

Install
go get github.com/komem3/wordimg/cmd/wordimg
Usage
Help
$ wordimg -h
Usage:
  wordimg [OPTIONS]

Application Options:
  -m, --message=   Message to write to image. required.
  -i, --imagePath= Path of the image to write. Default is 'unix_time.png
  -f, --font=      Path to font file. Only support ttf.
      --size=      Font size. Supports j${line} as a special format. If you
                   specify 'j1', the font size will fit on one line.
  -a, --align=     Word postion. 'left' or 'center'
  -w, --width=     Width of the generated image. (default: 512)
  -h, --height=    Height of the generated image. (default: 512)
  -c, --color=     Text color. Format is 'R:G:B'. Example: 255:255:0(yellow)

Help Options:
  -h, --help       Show this help message
Simple case
$ wordimg -m "Hello World"
wrote: 1612796180.png
Specify font
$ wordimg -m "こんにちは世界" -f ./SawarabiGothic-Regular.ttf
wrote: 1612796255.png

License

MIT

Author

komem3

Documentation

Overview

Package wordimg implements generator to create an image from text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertColor

func ConvertColor(str string) (*color.RGBA, error)

ConvertColor convert color.RGBA from "R:G:B" string.

Types

type Generator

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

Generator contain font data.

func NewGenerator

func NewGenerator(rand *rand.Rand, font []byte) *Generator

NewGenerator create Generator.

func (*Generator) GenerateImage

func (g *Generator) GenerateImage(w io.Writer, message string, op ...Option) error

GenerateImage generate image from given message and write the image file to io.Writer.

type Option

type Option func(*config)

Option is a setting value to image generation.

func WithAlignCenter

func WithAlignCenter() Option

WithAlignCenter center the text.

func WithColor

func WithColor(col *color.RGBA) Option

WithColor set color

func WithFontSize

func WithFontSize(f int) Option

WithFontSize set font size.

func WithHeight

func WithHeight(w int) Option

WithHeight set height.

func WithJustLine

func WithJustLine(l int) Option

WithJustLine specify how many lines.

func WithWidth

func WithWidth(w int) Option

WithWidth set width.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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