golimg

package module
v0.0.0-...-c94adaa Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 14 Imported by: 0

README

golimg

few utility functions for specific Image Manipulation in Go

Public Functions

DrawText{SrcImgPath, Dpi, FontPath, Hinting, FontSize, FontSpacing, FontColorName, MaxCharsPerLine, WhiteOnBlack, TextTitle}

  • DrawText.CreateImageWithText(text, saveAs string) is the primary function allowing creating Image with Text overlay

it will create a default 640x480 image if no SrcImgPath provided, to create custom image size.. other public functions can be used in combination which are chained together in here

  • DrawText.GetFont() (*truetype.Font, error)
  • DrawText.SetFgColor()
  • DrawText.CreateBgImage(imgW, imgH int) *image.RGBA
  • DrawText.LoadBgImage(imgpath string) (*image.RGBA, error)
  • DrawText.GetFontDrawer(rgba *image.RGBA) (*font.Drawer, error)
  • DrawText.AddText(drawer *font.Drawer, max image.Point, text string) error
  • DrawText.SaveImage(rgba *image.RGBA, outFilepath string) error

Documentation

Index

Constants

View Source
const (
	DefaultDpi             = 72
	DefaultFontFile        = "fonts/FFF_Tusj.ttf"
	DefaultHinting         = "none" // values: none, full
	DefaultFontSize        = 12     // value in points
	DefaultFontSpacing     = 1.25   // e.g. 2 means double spaced
	DefaultMaxCharsPerLine = 16
	DefaultWhiteOnBlack    = false // useful when creating image as well
	DefaultTextPointX      = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DrawText

type DrawText struct {
	SrcImgPath      string  `json:"src_img_path"`
	Dpi             float64 `json:"dpi"`
	FontPath        string  `json:"font_path"` // only TTF for now
	Hinting         string  `json:"hinting"`
	FontSize        float64 `json:"font_size"`
	FontSpacing     float64 `json:"font_spacing"`
	FontColorName   string  `json:"font_color_name"` // for names in colorname
	MaxCharsPerLine int     `json:"max_chars_per_line"`
	WhiteOnBlack    bool    `json:"white_on_black"`
	TextTitle       string  `json:"text_title"`
	FontColor       *image.Uniform
}

func (*DrawText) AddText

func (drawtxt *DrawText) AddText(drawer *font.Drawer, max image.Point, text string) error

Draw the text.

func (*DrawText) CreateBgImage

func (drawtxt *DrawText) CreateBgImage(imgW, imgH int) *image.RGBA

Draw the background and the guidelines.

func (*DrawText) CreateImageWithText

func (drawtxt *DrawText) CreateImageWithText(text, saveAs string) error

func (*DrawText) GetFont

func (drawtxt *DrawText) GetFont() (*truetype.Font, error)

Read the font data.

func (*DrawText) GetFontDrawer

func (drawtxt *DrawText) GetFontDrawer(rgba *image.RGBA) (*font.Drawer, error)

Get Font Drawer instance with destination image & font configs

func (*DrawText) LoadBgImage

func (drawtxt *DrawText) LoadBgImage(imgpath string) (*image.RGBA, error)

Load an existing Background image

func (*DrawText) SaveImage

func (drawtxt *DrawText) SaveImage(rgba *image.RGBA, outFilepath string) error

Save that RGBA image to disk.

func (*DrawText) SetFgColor

func (drawtxt *DrawText) SetFgColor()

Get Foreground Color, for text

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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