gomeme

package module
v0.0.0-...-66135d8 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: MIT Imports: 21 Imported by: 1

README

gomeme

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

Forked from: peterebden/gomeme and jpoz/gomeme

Installation

go get -u gitlab.com/koalalorenzo/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

type WebP

type WebP struct {
	Image image.Image
}

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

func (WebP) Bounds

func (i WebP) Bounds() image.Rectangle

Bounds return the bounds of the first frame

func (WebP) Write

func (i WebP) 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