gomeme

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

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

Go to latest
Published: Aug 18, 2017 License: MIT Imports: 19 Imported by: 0

README

gomeme

Take a gif/jpeg/png, make a meme. Written in Go (Golang)

Installation

go get -u github.com/jpoz/gomeme/cmd/gomeme

Usage

Usage: gomeme [options] input.gif output.gif

  -b string
        Bottom text of the meme.
  -f string
        TrueType font path. Default is Hack-Bold.ttf
  -fs float
        Font size of the text (default 42)
  -m int
        Margin around the text (default 10)
  -ss int
        Stroke size around the text (default 4)
  -t string
        Top text of the meme.
  -v    Displays more information.

Example

gomeme -t "Whatup internet?" -b "How you doing?" input.gif output.gif

output

Notes

impact.ttf From here

Documentation

Index

Constants

View Source
const DefaultDPI = 42

DefaultDPI is the fonts DPI

View Source
const DefaultFontSize = 42

DefaultFontSize is the default size of the font

View Source
const DefaultMargin = 10

DefaultMargin is the default distance between the text and the top and bottem

View Source
const DefaultStrokeSize = 4

DefaultStrokeSize default width of the stroke

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Config

type Config struct {
	FontPath        string
	FontSize        float64
	FontDPI         float64
	FontColor       image.Image
	FontStrokeSize  int
	FontStrokeColor color.Color

	Margin int

	TopText    string
	BottomText string
}

Config hold all the configuration needed to make a new meme. It Also produces the text image to be overlayed

func NewConfig

func NewConfig() *Config

NewConfig builds a default configuration.

func (*Config) TextImage

func (c *Config) TextImage(bounds image.Rectangle) (*image.RGBA, error)

TextImage produces a image of the bottom and top text

type GIF

type GIF struct {
	GIF *gif.GIF
}

GIF comprises of all things needed to create a new meme from a gif

func (GIF) Bounds

func (g GIF) Bounds() image.Rectangle

Bounds return the bounds of the first frame

func (GIF) Write

func (g GIF) Write(textImage *image.RGBA, w io.Writer) error

Write GIF to writer

type JPEG

type JPEG struct {
	Image image.Image
}

JPEG comprises of all things needed to create a new meme from a Image

func (JPEG) Bounds

func (i JPEG) Bounds() image.Rectangle

Bounds return the bounds of the first frame

func (JPEG) Write

func (i JPEG) Write(textImage *image.RGBA, w io.Writer) error

Write Image to writer

type Meme

type Meme struct {
	Config   *Config
	Memeable Memeable
}

Meme is the configuration and the "memable" image or gif

func (Meme) Write

func (m Meme) Write(w io.Writer) error

Write Meme to writer

type Memeable

type Memeable interface {
	Bounds() image.Rectangle
	Write(textImage *image.RGBA, w io.Writer) error
}

Memeable is takes a image of the text overlays it with its image and outputs it to the Writer

type PNG

type PNG struct {
	Image image.Image
}

PNG comprises of all things needed to create a new meme from a Image

func (PNG) Bounds

func (i PNG) Bounds() image.Rectangle

Bounds return the bounds of the first frame

func (PNG) Write

func (i PNG) Write(textImage *image.RGBA, w io.Writer) error

Write Image to writer

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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