Documentation
¶
Overview ¶
Package avif implements an AVIF image decoder based on libavif compiled to WASM.
Index ¶
- Constants
- Variables
- func Decode(r io.Reader, opts ...Options) (image.Image, error)
- func DecodeConfig(r io.Reader) (image.Config, error)
- func Dynamic() error
- func Encode(w io.Writer, m image.Image, o ...Options) error
- func EncodeAll(w io.Writer, anim *AVIF, o ...Options) error
- type AVIF
- type Exif
- type Options
Constants ¶
const DefaultQuality = 60
DefaultQuality is the default quality encoding parameter.
const DefaultSpeed = 10
DefaultSpeed is the default speed encoding parameter.
Variables ¶
var ( ErrMemRead = errors.New("avif: mem read failed") ErrMemWrite = errors.New("avif: mem write failed") ErrDecode = errors.New("avif: decode failed") ErrEncode = errors.New("avif: encode failed") )
Errors .
var ErrNoExif = errors.New("avif: no exif data")
ErrNoExif is returned by DecodeExif when the AVIF has no Exif item.
Functions ¶
func Decode ¶
Decode reads a AVIF image from r; pass Options{AutoRotate: true} to apply the orientation.
func DecodeConfig ¶
DecodeConfig returns the color model and dimensions of a AVIF image without decoding the entire image.
func Dynamic ¶ added in v0.2.1
func Dynamic() error
Dynamic returns error (if there was any) during opening dynamic/shared library.
Types ¶
type AVIF ¶ added in v0.1.5
type AVIF struct {
// Decoded images, NRGBA or NRGBA64.
Image []image.Image
// Delay times, one per frame, in seconds.
Delay []float64
// LoopCount is the number of times the animation repeats (0 = infinite).
LoopCount int
}
AVIF represents the possibly multiple images stored in a AVIF file.
type Exif ¶ added in v0.5.3
type Exif struct {
// Basic image info
Orientation int // EXIF orientation (1-8). 1 = normal, values 2-8 indicate rotation/flip.
Width int // Image width in pixels.
Height int // Image height in pixels.
// Camera info
Make string // Camera manufacturer (e.g., "Canon").
Model string // Camera model (e.g., "Canon EOS 5D Mark III").
Software string // Software used to process/create the image.
// Date/Time (format: "YYYY:MM:DD HH:MM:SS")
DateTime string // File modification date/time.
DateTimeOriginal string // Original capture date/time (when photo was taken).
// Exposure settings
ExposureTime float64 // Shutter speed in seconds (e.g., 0.004 = 1/250s).
FNumber float64 // Aperture f-number (e.g., 5.6 = f/5.6).
ISOSpeed int // ISO speed rating (e.g., 800).
FocalLength float64 // Lens focal length in millimeters.
Flash int // Flash mode/status (0 = no flash, non-zero = flash fired).
// GPS location
GPSLatitude float64 // Latitude in decimal degrees (positive = North, negative = South).
GPSLongitude float64 // Longitude in decimal degrees (positive = East, negative = West).
GPSAltitude float64 // Altitude in meters above sea level.
// Copyright/Author
Copyright string // Copyright notice.
Artist string // Creator/photographer name.
}
Exif holds the EXIF metadata decoded from an AVIF image.
type Options ¶ added in v0.2.5
type Options struct {
// Quality in the range [0,100]. Default is 60.
Quality int
// Quality in the range [0,100].
QualityAlpha int
// Speed in the range [0,10]. Slower should make for a better quality image in less bytes.
Speed int
// Chroma subsampling, 444|422|420.
ChromaSubsampling image.YCbCrSubsampleRatio
// Lossless enables lossless compression. Lossless ignores quality and forces 4:4:4 chroma.
Lossless bool
// AutoRotate applies the irot/imir orientation to the decoded image (Decode/DecodeAll only).
AutoRotate bool
}
Options are the encoding parameters.