thumbnail

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

type Encoder interface {
	// Encode encodes the image to a format.
	Encode(io.Writer, image.Image) error
	// Types returns the formats suffixes.
	Types() []string
	// MimeType returns the mimetype used by the encoder.
	MimeType() string
}

Encoder encodes the thumbnail to a specific format.

func EncoderForType

func EncoderForType(fileType string) Encoder

EncoderForType returns the encoder for a given file type or nil if the type is not supported.

type JpegEncoder

type JpegEncoder struct{}

JpegEncoder encodes to jpg.

func (JpegEncoder) Encode

func (e JpegEncoder) Encode(w io.Writer, i image.Image) error

Encode encodes to jpg

func (JpegEncoder) MimeType

func (e JpegEncoder) MimeType() string

MimeType returns the mimetype for jpg files.

func (JpegEncoder) Types

func (e JpegEncoder) Types() []string

Types returns the jpg suffixes.

type Manager

type Manager interface {
	// Get will return a thumbnail for a file
	Get(Request, image.Image) ([]byte, error)
	// GetStored loads the thumbnail from the storage.
	// It will return nil if no image is stored for the given context.
	GetStored(Request) []byte
}

Manager is responsible for generating thumbnails

type PngEncoder

type PngEncoder struct{}

PngEncoder encodes to png

func (PngEncoder) Encode

func (e PngEncoder) Encode(w io.Writer, i image.Image) error

Encode encodes to png format

func (PngEncoder) MimeType

func (e PngEncoder) MimeType() string

MimeType returns the mimetype for png files.

func (PngEncoder) Types

func (e PngEncoder) Types() []string

Types returns the png suffix

type Request

type Request struct {
	Resolution resolution.Resolution
	ImagePath  string
	Encoder    Encoder
	ETag       string
	Username   string
}

Request bundles information needed to generate a thumbnail for afile

type SimpleManager

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

SimpleManager is a simple implementation of Manager

func NewSimpleManager

func NewSimpleManager(storage storage.Storage, logger log.Logger) SimpleManager

NewSimpleManager creates a new instance of SimpleManager

func (SimpleManager) Get

func (s SimpleManager) Get(r Request, img image.Image) ([]byte, error)

Get implements the Get Method of Manager

func (SimpleManager) GetStored

func (s SimpleManager) GetStored(r Request) []byte

GetStored tries to get the stored thumbnail and return it. If there is no cached thumbnail it will return nil

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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