heic

package module
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 18 Imported by: 11

README

heic

Status Go Reference

Go decoder for HEIC Image File Format (HEVC in HEIF).

Based on the Rust heic decoder compiled to WASM and run with wazero (CGo-free).

The library will first try to use a libheif dynamic/shared library (if installed) via purego and will fall back to the embedded WASM.

Build tags

  • nodynamic - do not use dynamic/shared library (use only WASM)
  • wasm2go - transpile the WASM to Go with wasm2go instead of running it with wazero

Documentation

Overview

Package heic implements an HEIC image decoder based on the pure-Rust heic crate compiled to WASM (run via wazero, or transpiled with the wasm2go build tag), or libheif/libde265 via a dynamic library.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMemRead  = errors.New("heic: mem read failed")
	ErrMemWrite = errors.New("heic: mem write failed")
	ErrDecode   = errors.New("heic: decode failed")
)

Errors .

View Source
var ErrNoExif = errors.New("heic: no exif data")

ErrNoExif is returned by DecodeExif when the HEIC image has no EXIF metadata.

View Source
var ForceWasmMode bool

ForceWasmMode, if true, forces using the WASM-based decoder even if a dynamic/shared library is available.

This exists mainly for testing purposes.

It is not safe to change this concurrently with any other use of this package.

Functions

func Decode

func Decode(r io.Reader) (image.Image, error)

Decode reads a HEIC image from r; for an image sequence it returns the first frame.

func DecodeConfig

func DecodeConfig(r io.Reader) (image.Config, error)

DecodeConfig returns the color model and dimensions of a HEIC 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 Exif added in v0.6.1

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 a HEIC image.

func DecodeExif added in v0.6.1

func DecodeExif(r io.Reader) (*Exif, error)

DecodeExif reads the EXIF metadata from a HEIC image, or returns ErrNoExif if there is none. Orientation is already applied by the decoder, so Exif.Orientation is informational.

type HEIC added in v0.7.0

type HEIC struct {
	Image []image.Image
	Delay []float64
}

HEIC holds the decoded frames of a HEIC image sequence and their per-frame delays in seconds.

func DecodeAll added in v0.7.0

func DecodeAll(r io.Reader) (*HEIC, error)

DecodeAll reads a HEIC image sequence from r and returns all frames; a still image yields one frame.

Jump to

Keyboard shortcuts

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