image

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCacheSize = 10

Variables

This section is empty.

Functions

func AutoLoad

func AutoLoad(r io.Reader, ext string) (image.Image, error)

load image data from io.Reader r with its image type, png, jpeg, and jpg, and return loaded image with error. error contains unsupported extension.

func AutoLoadFile

func AutoLoadFile(file string) (image.Image, error)

auto detect file extension, png, jpeg, and jpg, and return loaded image data with error. error contains file not found, unsupported extension, ... etc.

Types

type LoadOptions added in v0.6.0

type LoadOptions struct {
	// Size of resized image. Empty this means no resized.
	// If either X or Y of size is zero, auto filled it by calculating
	// from the other with keep aspect ratio.
	// For example, Let source image size (W, H) = (1920, 1080) and resized size
	// (RW, RH) = (960, 0) then auto-filled resized size (RW', RH') = (960, 540)
	// since 1920:1080 = 960:540.
	ResizedSize image.Point
}

LoadOptions is options for image loading.

type Loader added in v0.6.0

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

Loader holds image caches. concurrent use is OK.

func NewLoader added in v0.6.0

func NewLoader(cachedSize int) *Loader

Loader has cachedSize cache entries. the oldest image is removed from cache using LRU. use DefaultCacheSize if cachedSize <= 0.

func (*Loader) Get added in v0.6.0

func (l *Loader) Get(file string) (image.Image, error)

get cached image by using image's file name. if not found, load image data from file and return loaded image with loading error. error nil means loaded image found.

func (*Loader) GetWithOptions added in v0.6.0

func (l *Loader) GetWithOptions(file string, opt LoadOptions) (image.Image, error)

It is almost same as Get(), except that it accepts options for loaded image property.

Jump to

Keyboard shortcuts

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