imaging

package
v0.1.4-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Height

type Height int

Height defines the height of the thumbnail.

type InMemoryThumbnailer

type InMemoryThumbnailer struct{}

InMemoryThumbnailer is for resizing images to thumbnails in memory (doesn't save to temp file, etc).

func NewInMemoryThumbnailer

func NewInMemoryThumbnailer() *InMemoryThumbnailer

NewInMemoryThumbnailer returns a new image thumbnailer.

func (*InMemoryThumbnailer) Resize

func (t *InMemoryThumbnailer) Resize(body io.Reader, width, height int) (*bytes.Buffer, error)

Resize resizes the image to the given width and height.

type S3ThumbnailUploader

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

S3ThumbnailUploader is for generating and uploading thumbnails to the remote storage.

func NewS3ThumbnailUploader

func NewS3ThumbnailUploader(s storage.Storage, thumbnailer Thumbnailer) *S3ThumbnailUploader

NewS3ThumbnailUploader creates a new s3 thumbnail uploader.

func (*S3ThumbnailUploader) Generate

func (u *S3ThumbnailUploader) Generate(key string, opts *ThumbnailOptions) ([]*ThumbnailResult, error)

Generate generates thumbnails for the given key stored in S3.

type ThumbnailOptions

type ThumbnailOptions struct {
	Sizes          []*ThumbnailSize         // The widths and heights for the thumbnails.
	NamingStrategy storage.FileNameStrategy // The strategy for generating thumbnail filenames.
	RemoteDir      string                   // The remote directory to upload the thumbnails.
}

ThumbnailOptions defines options for generating thumbnails.

func NewDefaultThumbnailOptions

func NewDefaultThumbnailOptions(remoteDir string, sizes ...*ThumbnailSize) *ThumbnailOptions

NewDefaultThumbnailOptions conveniently creates thumbnail options from the parameters with the crc32 time naming strategy as the default filename strat.

type ThumbnailResult

type ThumbnailResult struct {
	Pathname   string
	Dimensions *ThumbnailSize
}

ThumbnailResult is the resulting thumbnail generated.

type ThumbnailSize

type ThumbnailSize struct {
	Width  Width
	Height Height
}

ThumbnailSize defines the width and height of the thumbnails.

func NewThumbnailSize

func NewThumbnailSize(width, height int) *ThumbnailSize

NewThumbnailSize creates a new thumbnail size for the given width and height.

type ThumbnailUploader

type ThumbnailUploader interface {
	Generate(key string, opts *ThumbnailOptions) ([]*ThumbnailResult, error)
}

ThumbnailUploader is for uploading generating and uploading thumbnails.

type Thumbnailer

type Thumbnailer interface {
	Resize(body io.Reader, width, height int) (*bytes.Buffer, error)
}

Thumbnailer is the interface for generating thumbnails.

type Width

type Width int

Width defines the width of the thumbnail.

Jump to

Keyboard shortcuts

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