image

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPoolSize = 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 Pool

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

Pool holds image caches. concurrent use is OK.

func NewPool

func NewPool(cachedSize int) *Pool

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

func (*Pool) Get

func (p *Pool) 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.

Jump to

Keyboard shortcuts

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