heicexif

package module
v2.0.0-...-62067e4 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 12 Imported by: 2

Documentation

Overview

Package heicexif marries HEIC-parsing to EXIF-parsing and equips go-exif- knife for HEIC support.

Index

Examples

Constants

View Source
const (

	// MinimumHeicStreamLengthForDetection describes the minimum amount of data
	// required to detect HEIC content.
	MinimumHeicStreamLengthForDetection = 1000

	// HeicMimeType describes the theoretical, official HEIC mime-type
	// (theoretical because it's not ubiquitously supported/known in tooling,
	// yet).
	HeicMimeType = "image/heif"
)

Variables

View Source
var (
	// HeicBrands is the list of MP4 brands that are associated with HEIC
	// streams.
	HeicBrands = sort.StringSlice{
		"mif1",
		"msf1",
		"heic",
	}
)

Functions

This section is empty.

Types

type HeicExifContext

type HeicExifContext []byte

HeicExifContext is just a simple type-alias for a byte-array.

func (HeicExifContext) Exif

func (hec HeicExifContext) Exif() (rootIfd *exif.Ifd, data []byte, err error)

Exif parses the raw EXIF data and returns the root IFD.

type HeicExifMediaParser

type HeicExifMediaParser struct {
}

HeicExifMediaParser satisfies the `riimage.MediaParser` interface.

func NewHeicExifMediaParser

func NewHeicExifMediaParser() *HeicExifMediaParser

NewHeicExifMediaParser returns a new HeicExifMediaParser instance.

func (*HeicExifMediaParser) LooksLikeFormat

func (hemp *HeicExifMediaParser) LooksLikeFormat(data []byte) bool

LooksLikeFormat parses the data to determine if it's a compatible format.

Example
filepath := path.Join(assetsPath, testImageRelFilepathWithExif)

f, err := os.Open(filepath)
log.PanicIf(err)

defer f.Close()

data := make([]byte, MinimumHeicStreamLengthForDetection)

_, err = io.ReadFull(f, data)
log.PanicIf(err)

hemp := new(HeicExifMediaParser)

doesLookLike := hemp.LooksLikeFormat(data)
fmt.Printf("%v\n", doesLookLike)
Output:

true

func (*HeicExifMediaParser) Parse

func (hemp *HeicExifMediaParser) Parse(rs io.ReadSeeker, size int) (mc riimage.MediaContext, err error)

Parse parses a stream using an `io.ReadSeeker`.

Example
filepath := path.Join(assetsPath, testImageRelFilepathWithExif)

f, err := os.Open(filepath)
log.PanicIf(err)

defer f.Close()

hemp := new(HeicExifMediaParser)

mc, err := hemp.Parse(f, 0)
log.PanicIf(err)

rootIfd, _, err := mc.Exif()
log.PanicIf(err)

fmt.Println(rootIfd)
Output:

Ifd<ID=(0) IFD-PATH=[IFD] INDEX=(0) COUNT=(4) OFF=(0x0008) CHILDREN=(0) PARENT=(0x0000) NEXT-IFD=(0x0000)>

func (*HeicExifMediaParser) ParseBytes

func (hemp *HeicExifMediaParser) ParseBytes(data []byte) (mc riimage.MediaContext, err error)

ParseBytes parses a stream direct from bytes.

Example
filepath := path.Join(assetsPath, testImageRelFilepathWithExif)

b, err := ioutil.ReadFile(filepath)
log.PanicIf(err)

hemp := new(HeicExifMediaParser)

mc, err := hemp.ParseBytes(b)
log.PanicIf(err)

rootIfd, _, err := mc.Exif()
log.PanicIf(err)

fmt.Println(rootIfd)
Output:

Ifd<ID=(0) IFD-PATH=[IFD] INDEX=(0) COUNT=(4) OFF=(0x0008) CHILDREN=(0) PARENT=(0x0000) NEXT-IFD=(0x0000)>

func (*HeicExifMediaParser) ParseFile

func (hemp *HeicExifMediaParser) ParseFile(filepath string) (mc riimage.MediaContext, err error)

ParseFile parses a stream using a file.

Example
filepath := path.Join(assetsPath, testImageRelFilepathWithExif)

hemp := new(HeicExifMediaParser)

mc, err := hemp.ParseFile(filepath)
log.PanicIf(err)

rootIfd, _, err := mc.Exif()
log.PanicIf(err)

fmt.Println(rootIfd)
Output:

Ifd<ID=(0) IFD-PATH=[IFD] INDEX=(0) COUNT=(4) OFF=(0x0008) CHILDREN=(0) PARENT=(0x0000) NEXT-IFD=(0x0000)>

Jump to

Keyboard shortcuts

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