go4.org: go4.org/media/heif Index | Files | Directories

package heif

import "go4.org/media/heif"

Package heif reads HEIF containers, as found in Apple HEIC/HEVC images. This package does not decode images; it only reads the metadata.

This package is a work in progress and makes no API compatibility promises.


Package Files



var ErrNoEXIF = errors.New("heif: no EXIF found")

ErrNoEXIF is returned by File.EXIF when a file does not contain an EXIF item.

var ErrUnknownItem = errors.New("heif: unknown item")

ErrUnknownItem is returned by File.ItemByID for unknown items.

type BoxMeta Uses

type BoxMeta struct {
    FileType     *bmff.FileTypeBox
    Handler      *bmff.HandlerBox
    PrimaryItem  *bmff.PrimaryItemBox
    ItemInfo     *bmff.ItemInfoBox
    Properties   *bmff.ItemPropertiesBox
    ItemLocation *bmff.ItemLocationBox

BoxMeta contains the low-level BMFF metadata boxes.

func (*BoxMeta) EXIFItemID Uses

func (m *BoxMeta) EXIFItemID() uint32

EXIFItemID returns the item ID of the EXIF part, or 0 if not found.

type File Uses

type File struct {
    // contains filtered or unexported fields

File represents a HEIF file.

Methods on File should not be called concurrently.

func Open Uses

func Open(f io.ReaderAt) *File

Open returns a handle to access a HEIF file.

func (*File) EXIF Uses

func (f *File) EXIF() ([]byte, error)

EXIF returns the raw EXIF data from the file. The error is ErrNoEXIF if the file did not contain EXIF.

The raw EXIF data can be parsed by the github.com/rwcarlsen/goexif/exif package's Decode function.

func (*File) ItemByID Uses

func (f *File) ItemByID(id uint32) (*Item, error)

ItemByID by returns the file's Item of a given ID. If the ID is known, the returned error is ErrUnknownItem.

func (*File) PrimaryItem Uses

func (f *File) PrimaryItem() (*Item, error)

PrimaryItem returns the HEIF file's primary item.

type Item Uses

type Item struct {
    ID         uint32
    Info       *bmff.ItemInfoEntry
    Location   *bmff.ItemLocationBoxEntry // location in file
    Properties []bmff.Box
    // contains filtered or unexported fields

Item represents an item in a HEIF file.

func (*Item) Rotations Uses

func (it *Item) Rotations() int

Rotations returns the number of 90 degree rotations counter-clockwise that this image should be rendered at, in the range [0,3].

func (*Item) SpatialExtents Uses

func (it *Item) SpatialExtents() (width, height int, ok bool)

SpatialExtents returns the item's spatial extents property values, if present, not correcting from any camera rotation metadata.

func (*Item) VisualDimensions Uses

func (it *Item) VisualDimensions() (width, height int, ok bool)

VisualDimensions returns the item's width and height after correcting for any rotations.


bmffPackage bmff reads ISO BMFF boxes, as used by HEIF, etc.
dumpheifThe dumpheif program dumps the structure and metadata of a HEIF file.

Package heif imports 5 packages (graph) and is imported by 7 packages. Updated 2019-06-18. Refresh now. Tools for package owners.