fit

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fit

type Fit struct {
	Width  string `json:"width,omitempty"`
	Height string `json:"height,omitempty"`
}

Fit scales a image to fit to the specified maximum width and height using a linear filter, the image aspect ratio is preserved. If the image already fits inside the bounds, nothing will be done.

func (Fit) Apply

func (f Fit) Apply(repl *caddy.Replacer, img image.Image) (image.Image, error)

Apply applies the image filter to an image and returns the new image.

type FitFactory

type FitFactory struct{}

FitFactory creates Fit instances.

func (FitFactory) Name

func (ff FitFactory) Name() string

Name returns the name of the filter, which is also the directive used in the image filter block.

func (FitFactory) New

func (ff FitFactory) New(args ...string) (imagefilter.Filter, error)

New initialises and returns a configured Fit instance.

Syntax:

fit <width> <height>

Parameters:

width must be a positive integer and determines the maximum width.

height must be a positive integer and determines the maximum height.

func (FitFactory) Unmarshal

func (ff FitFactory) Unmarshal(data []byte) (imagefilter.Filter, error)

Unmarshal decodes JSON data and returns a Fit instance.

Jump to

Keyboard shortcuts

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