showerglass

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToGrayscale

func ConvertToGrayscale(src image.Image) image.Image

ConvertToGrayscale will convert an image from color to grayscale.

func FaceMask

func FaceMask(input io.Reader, opts ...Options) (image.Image, string, error)

FaceMask accepts an io.Reader (usually an *os.File) and returns an image with the FaceMask filter applied. The type of image format used for the input is also returned.

func Resize

func Resize(src image.Image, nh, nw int, alg ResizeAlg) (image.Image, error)

Resize will resize src to a new height (nh) and new width (nw). For the Caire algorithm (default), src must be an *image.NRGBA.

See: https://pkg.go.dev/github.com/rocketlaunchr/showerglass/core#ResizeAlg

Types

type MaxPoints

type MaxPoints func(float64) int

MaxPoints takes a value between 0 and 1 and returns a calibrated MaxPoints value for use with TriangleConfig. 0 means the face is closer to the original. 1 means the face is maximally obfuscated.

See: https://pkg.go.dev/github.com/rocketlaunchr/showerglass/core#TriangleConfig

NOTE: The implementation is experimental and subject to change. No backward-compatability guarantee!

type Options

type Options struct {

	// NewHeight, when set, is the height of the image after the resize process.
	// If a float64 is provided, NewHeight is interpreted as a percentage of the original image.
	// An int can also be provided to mean the actual NewHeight.
	// A value of 0 indicates no change from the original height.
	NewHeight interface{}

	// NewWidth, when set, is the width of the image after the resize process.
	// If a float64 is provided, NewWidth is interpreted as a percentage of the original image.
	// An int can also be provided to mean the actual NewWidth.
	// A value of 0 indicates no change from the original width.
	NewWidth interface{}

	// TriangleConfig is called for each detected face. A *TriangleConfig must be returned to
	// modify the delaunay triangulation algorithm parameters.
	// If nil is returned, no triangulation is performed.
	//
	// facearea is the size of the detected face. You can calibrate the returned *TriangleConfig parameters based on
	// the area. The 5 most relevant parameters are BlurRadius, BlurFactor, EdgeFactor, PointRate and MaxPoints.
	//
	// QRank indicates the rank of all the "detected faces". If only one face is expected,
	// then you can return nil for all QRank > 0. If the Q value is _sufficiently_ low, you can
	// presume a false positive and also return nil.
	//
	// See: https://pkg.go.dev/github.com/esimov/triangle/v2#Processor
	TriangleConfig func(QRank, facearea int, Q float32, h, w int, c MaxPoints) *TriangleConfig

	// ResizeAlg sets which resizing algorithm to use.
	// The default is "Caire".
	ResizeAlg ResizeAlg
}

Options is used to adjust behavior of the FaceMask function.

type ResizeAlg

type ResizeAlg int

ResizeAlg defines the algorithm to use for resizing purposes.

const (
	// Caire uses a content-aware image resizing algorithm (slowest, but more sophisticated results).
	// See: https://github.com/esimov/caire
	//
	// This is the default.
	Caire ResizeAlg = iota

	// NearestNeighbor is very fast (but very low quality results).
	// See: https://pkg.go.dev/golang.org/x/image/draw#pkg-variables
	NearestNeighbor

	// ApproxBiLinear is fast (but medium quality results).
	// See: https://pkg.go.dev/golang.org/x/image/draw#pkg-variables
	ApproxBiLinear

	// BiLinear is slow (but high quality results).
	// See: https://pkg.go.dev/golang.org/x/image/draw#pkg-variables
	BiLinear

	// CatmullRom is slower (but very high quality results).
	// See: https://pkg.go.dev/golang.org/x/image/draw#pkg-variables
	CatmullRom
)

type TriangleConfig

type TriangleConfig = triangle.Processor

TriangleConfig is a triangle.Processor.

See: https://pkg.go.dev/github.com/esimov/triangle/v2#Processor

Jump to

Keyboard shortcuts

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