imagecat

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 5 Imported by: 0

README

imagecat

Concatenate any number of images into a single image on x or y axis with optional alignment centering

Installation

go get github.com/DillonStreator/imagecat

Usage

import (
    "image"

    "github.com/DillonStreator/imagecat"
)

func main () {

    images := []image.Image{
        // ... some images
    }

    concater := imagecat.NewConcater(images...)

    img, err := concater.Concat(imagecat.WithAxis(imagecat.ConcatAxisY), imagecat.WithAlignment(imagecat.ConcatAlignmentCenter))
    if err != nil { /* handle error */ }

    // ... do something with image

    // ... concat same images on different axis and different alignment
    img, err = concater.Concat(imagecat.WithAxis(imagecat.ConcatAxisX), imagecat.WithAlignment(imagecat.ConcatAlignmentNone))
    if err != nil { /* handle error */ }

    // ... do something with image

}

Examples

Input images

concat on x axis with no alignment

concat on x axis with center alignment

concat on y axis with no alignment

concat on y axis with center alignment

Documentation

Index

Constants

View Source
const (
	// Specifies the axis with which the images will be concatenated on
	ConcatAxisX ConcatAxis = iota
	ConcatAxisY

	// Specifies the alignment that will be applied to the images
	ConcatAlignmentNone ConcatAlignment = iota
	ConcatAlignmentCenter
)

Variables

This section is empty.

Functions

func WithAlignment

func WithAlignment(alignment ConcatAlignment) opt

func WithAxis

func WithAxis(axis ConcatAxis) opt

Types

type ConcatAlignment

type ConcatAlignment int

type ConcatAxis

type ConcatAxis int

type Concater

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

func NewConcater

func NewConcater(images ...image.Image) *Concater

NewConcater creates a new concater

func (*Concater) Add

func (c *Concater) Add(images ...image.Image)

Add adds images to the concater for later concatenation

func (*Concater) Clear

func (c *Concater) Clear()

Clear clears the images and any calculated max/total widths and heights

func (*Concater) Concat

func (c *Concater) Concat(opts ...opt) (*image.RGBA, error)

Concat concatenates the added images with axis and alignment options

Jump to

Keyboard shortcuts

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