imaging

package
v6.0.0-...-cfe9101 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: AGPL-3.0, Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/*
	  EXIF Image Orientations
	  1        2       3      4         5            6           7          8

	  888888  888888      88  88      8888888888  88                  88  8888888888
	  88          88      88  88      88  88      88  88          88  88      88  88
	  8888      8888    8888  8888    88          8888888888  8888888888          88
	  88          88      88  88
	  88          88  888888  888888
	*/
	Upright = iota + 1
	UprightMirrored
	UpsideDown
	UpsideDownMirrored
	RotatedCWMirrored
	RotatedCCW
	RotatedCCWMirrored
	RotatedCW
)

Variables

This section is empty.

Functions

func FillCenter

func FillCenter(img image.Image, w, h int) *image.NRGBA

FillCenter creates an image with the specified dimensions and fills it with the centered and scaled source image.

func FillImageTransparency

func FillImageTransparency(img image.Image, c color.Color)

FillImageTransparency fills in-place all the fully transparent pixels of the input image with the given color.

func GenerateMiniPreviewImage

func GenerateMiniPreviewImage(img image.Image, w, h, q int) ([]byte, error)

GenerateMiniPreviewImage generates the mini preview for the given image.

func GeneratePreview

func GeneratePreview(img image.Image, width int) image.Image

GeneratePreview generates the preview for the given image.

func GenerateThumbnail

func GenerateThumbnail(img image.Image, width, height int) image.Image

GenerateThumbnail generates the thumbnail for the given image.

func GetDimensions

func GetDimensions(imageData io.Reader) (int, int, error)

GetDimensions returns the dimensions for the given encoded image data.

func GetImageOrientation

func GetImageOrientation(input io.Reader) (int, error)

GetImageOrientation reads the input data and returns the EXIF encoded image orientation.

func MakeImageUpright

func MakeImageUpright(img image.Image, orientation int) image.Image

MakeImageUpright changes the orientation of the given image.

Types

type Decoder

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

Decoder holds the necessary state to decode images. This is safe to be used from multiple goroutines.

func NewDecoder

func NewDecoder(opts DecoderOptions) (*Decoder, error)

NewDecoder creates and returns a new image decoder with the given options.

func (*Decoder) Decode

func (d *Decoder) Decode(rd io.Reader) (img image.Image, format string, err error)

Decode decodes the given encoded data and returns the decoded image.

func (*Decoder) DecodeConfig

func (d *Decoder) DecodeConfig(rd io.Reader) (image.Config, string, error)

DecodeConfig returns the image config for the given data.

func (*Decoder) DecodeMemBounded

func (d *Decoder) DecodeMemBounded(rd io.Reader) (img image.Image, format string, releaseFunc func(), err error)

DecodeMemBounded works similarly to Decode but also returns a release function that must be called when access to the raw image is not needed anymore. This sets the raw image data pointer to nil in an attempt to help the GC to re-use the underlying data as soon as possible.

type DecoderOptions

type DecoderOptions struct {
	// The level of concurrency for the decoder. This defines a limit on the
	// number of concurrently running encoding goroutines.
	ConcurrencyLevel int
}

DecoderOptions holds configuration options for an image decoder.

type Encoder

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

Decoder holds the necessary state to encode images. This is safe to be used from multiple goroutines.

func NewEncoder

func NewEncoder(opts EncoderOptions) (*Encoder, error)

NewEncoder creates and returns a new image encoder with the given options.

func (*Encoder) EncodeJPEG

func (e *Encoder) EncodeJPEG(wr io.Writer, img image.Image, quality int) error

EncodeJPEG encodes the given image in JPEG format and writes the data to the passed writer.

func (*Encoder) EncodePNG

func (e *Encoder) EncodePNG(wr io.Writer, img image.Image) error

EncodePNG encodes the given image in PNG format and writes the data to the passed writer.

type EncoderOptions

type EncoderOptions struct {
	// The level of concurrency for the encoder. This defines a limit on the
	// number of concurrently running encoding goroutines.
	ConcurrencyLevel int
}

EncoderOptions holds configuration options for an image encoder.

type SVGInfo

type SVGInfo struct {
	Width  int
	Height int
}

SVGInfo holds information for a SVG image.

func ParseSVG

func ParseSVG(svgReader io.Reader) (SVGInfo, error)

ParseSVG returns information for the given SVG input data.

Jump to

Keyboard shortcuts

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