image

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxCoverWidth and MaxCoverHeight bound per-request work and cache churn.
	MaxCoverWidth  = 600
	MaxCoverHeight = 900
)

Variables

View Source
var (
	ErrInvalidDimensions = errors.New("invalid resize dimensions")
	ErrImageTooLarge     = errors.New("image is too large")
	ErrUnsupportedFormat = errors.New("unsupported image format")
)

Functions

func Resize

func Resize(src io.Reader, width, height int) ([]byte, error)

Resize takes an image from the provided io.Reader, resizes it to fit within the specified width and height while preserving the aspect ratio using Lanczos resampling, and returns the resulting image as a JPEG byte slice.

func ValidateDimensions

func ValidateDimensions(width, height int) error

ValidateDimensions returns an error when requested cover dimensions exceed the supported bounds for OPDS thumbnail/cover generation.

Types

type DiskCache

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

DiskCache implements a disk-based LRU cache for images.

func NewDiskCache

func NewDiskCache(path string, maxCount int) (*DiskCache, error)

NewDiskCache creates a new DiskCache.

func (*DiskCache) Get

func (c *DiskCache) Get(key string) ([]byte, error)

Get retrieves an image from the cache.

func (*DiskCache) Put

func (c *DiskCache) Put(key string, data []byte) error

Put adds an image to the cache.

Jump to

Keyboard shortcuts

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