native

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOrientation added in v0.0.4

func GetOrientation(r io.Reader) (int, io.Reader)

GetOrientation returns the EXIF orientation tag from the given image and a new io.Reader with the same state as the original reader r.

Types

type BildProcessor

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

BildProcessor uses bild library to process images using native Golang image.Image interface

func NewBildProcessor

func NewBildProcessor(opts ...ProcessorOption) *BildProcessor

NewBildProcessor creates a new BildProcessor, if called without parameters encoders will be default

func (*BildProcessor) Blur added in v0.0.5

func (bp *BildProcessor) Blur(img image.Image, radius float64) image.Image

Blur takes an input image and blur radius and returns the Gausian blurred image

func (*BildProcessor) Crop

func (bp *BildProcessor) Crop(img image.Image, width, height int, point processor.Point) image.Image

Crop takes an input image, width, height and a Point and returns the cropped image

func (*BildProcessor) Decode added in v0.0.3

func (bp *BildProcessor) Decode(data []byte) (image.Image, string, error)

Decode takes a byte array and returns the decoded image, format, or the error

func (*BildProcessor) Encode added in v0.0.3

func (bp *BildProcessor) Encode(img image.Image, fmt string) ([]byte, error)

Encode takes an image and the preferred format (extension) of the output Current supported format are "png", "jpg" and "jpeg"

func (*BildProcessor) FixOrientation added in v0.0.4

func (bp *BildProcessor) FixOrientation(img image.Image, orientation int) image.Image

FixOrientation takes an image and it's EXIF orientation To get the orientation of the image see GetOrientation (exif.go)

func (*BildProcessor) Flip added in v0.0.4

func (bp *BildProcessor) Flip(img image.Image, mode string) image.Image

Flip takes an input image and returns the image flipped. The direction of flip is determined by the specified mode - 'v' for a vertical flip, 'h' for a horizontal flip and 'vh'(or 'hv') for both.

func (*BildProcessor) GrayScale

func (bp *BildProcessor) GrayScale(img image.Image) image.Image

GrayScale takes an input image and returns the grayscaled image

func (*BildProcessor) Overlay added in v0.0.10

func (bp *BildProcessor) Overlay(base []byte, overlays []*processor.OverlayAttrs) ([]byte, error)

Overlay takes a base image and array of overlay images and returns the final overlayed image bytes or error

func (*BildProcessor) Resize

func (bp *BildProcessor) Resize(img image.Image, width, height int) image.Image

Resize takes an input image, width and height and returns the re-sized image

func (*BildProcessor) Rotate added in v0.0.4

func (bp *BildProcessor) Rotate(img image.Image, angle float64) image.Image

Rotate takes an input image and returns a image rotated by the specified degrees. The rotation is applied clockwise, and fractional angles are also supported.

func (*BildProcessor) Scale added in v0.0.8

func (bp *BildProcessor) Scale(img image.Image, width, height int) image.Image

Scale takes an input image, width and height and returns the re-sized image without maintaining the original aspect ratio

func (*BildProcessor) Watermark

func (bp *BildProcessor) Watermark(base []byte, overlay []byte, opacity uint8) ([]byte, error)

Watermark takes an input byte array, overlay byte array and opacity value and returns the watermarked image bytes or error

type Encoder added in v0.0.3

type Encoder interface {
	Encode(img image.Image) ([]byte, error)
}

Encoder is an interface to Encode image and return the encoded byte array or error

type Encoders added in v0.0.3

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

Encoders is a struct to store all supported encoders so that we don't have to create new encoder every time

func NewEncoders added in v0.0.3

func NewEncoders(opts ...EncodersOption) *Encoders

NewEncoders creates a new Encoders, if called without parameter (builder), all encoders option will be default

func (*Encoders) GetEncoder added in v0.0.3

func (e *Encoders) GetEncoder(img image.Image, ext string) Encoder

GetEncoder takes an input of image and extension and return the appropriate Encoder for encoding the image

type EncodersOption added in v0.0.5

type EncodersOption func(*Encoders)

EncodersOption represents builder function for Encoders

func WithJpegEncoder added in v0.0.5

func WithJpegEncoder(jpegEncoder *JpegEncoder) EncodersOption

WithJpegEncoder is a builder function for setting custom JpegEncoder

func WithPngEncoder added in v0.0.5

func WithPngEncoder(pngEncoder *PngEncoder) EncodersOption

WithPngEncoder is a builder function for setting custom PngEncoder

func WithWebPEncoder added in v0.0.5

func WithWebPEncoder(webPEncoder *WebPEncoder) EncodersOption

WithWebPEncoder is a builder function for setting custom WebPEncoder

type JpegEncoder added in v0.0.3

type JpegEncoder struct {
	Option *jpeg.Options
}

JpegEncoder is an object to encode image to byte array with jpeg format

func (*JpegEncoder) Encode added in v0.0.3

func (e *JpegEncoder) Encode(img image.Image) ([]byte, error)

type NopEncoder added in v0.0.3

type NopEncoder struct{}

NopEncoder is a no-op encoder object for unsupported format and will return error

func (*NopEncoder) Encode added in v0.0.3

func (e *NopEncoder) Encode(img image.Image) ([]byte, error)

type PngEncoder added in v0.0.3

type PngEncoder struct {
	Encoder *png.Encoder
}

PngEncoder is an object to encode image to byte array with png format

func (*PngEncoder) Encode added in v0.0.3

func (e *PngEncoder) Encode(img image.Image) ([]byte, error)

type ProcessorOption added in v0.0.5

type ProcessorOption func(*BildProcessor)

ProcessorOption represents builder function for BildProcessor

func WithEncoders added in v0.0.5

func WithEncoders(encoders *Encoders) ProcessorOption

WithEncoders is a builder function to set custom Encoders for BildProcessor

type WebPEncoder added in v0.0.5

type WebPEncoder struct {
	Option *webp.Options
}

WebPEncoder is an object to encode image to byte array with webp format

func (*WebPEncoder) Encode added in v0.0.5

func (e *WebPEncoder) Encode(img image.Image) ([]byte, error)

Jump to

Keyboard shortcuts

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