images

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidExtension

func ValidExtension(ext string) bool

Types

type Config

type Config struct {
	Conversion Conversion
	JPEG       JPEGOptions
	PNG        PNGOptions
	WebP       WebPOptions
	Resize     Resize
}

func DefaultConfig

func DefaultConfig() Config

type Conversion

type Conversion struct {
	Enabled bool
	Format  Format
}

type Format

type Format = string
const (
	JPEG Format = "jpeg"
	JPG  Format = "jpg"
	GIF  Format = "gif"
	PNG  Format = "png"
	WebP Format = "webp"
)

type ImageProcessor

type ImageProcessor interface {
	Config() Config
	Optimize(ctx context.Context, r io.Reader) ([]byte, error)
	Resize(ctx context.Context, r io.Reader) ([]byte, error)
	Convert(ctx context.Context, r io.Reader, toFormat string) ([]byte, error)
}

func New

func New() ImageProcessor

func NewWithConfig

func NewWithConfig(cfg Config) ImageProcessor

type JPEGOptions

type JPEGOptions struct {
	Quality int
}

type PNGOptions

type PNGOptions struct {
	Compression png.CompressionLevel
	Lossless    bool
	Optimize    bool
}

type Resize

type Resize struct {
	Enabled   bool
	MaxWidth  int
	MaxHeight int
}

type WebPOptions

type WebPOptions struct {
	Quality  float32 // 0-100 for lossy, 0-9 for lossless
	Lossless bool
}

Jump to

Keyboard shortcuts

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