tag

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package tag provides types and functions for decoding Exif Tags

Index

Constants

View Source
const (
	TypeByteSize           = 1
	TypeASCIISize          = 1
	TypeASCIINoNulSize     = 1
	TypeShortSize          = 2
	TypeLongSize           = 4
	TypeRationalSize       = 8
	TypeSignedLongSize     = 4
	TypeSignedRationalSize = 8
	TypeIfdSize            = 4
)

Tag sizes

Variables

View Source
var (
	ErrEmptyTag      = errors.New("error empty tag")
	ErrTagNotValid   = errors.New("error tag not valid")
	ErrNotEnoughData = errors.New("error not enough data to parse tag")
)

Errors

View Source
var (
	ErrTagTypeNotValid = errors.New("Tag type not valid")
)

Errors

Functions

This section is empty.

Types

type ID

type ID uint16

ID is the uint16 representation of an IFD tag

func (ID) String

func (id ID) String() string

type Offset

type Offset uint32

Offset for reading data

type Rational

type Rational struct {
	Numerator   uint32
	Denominator uint32
}

Rational is a rational value

type SRational

type SRational struct {
	Numerator   int32
	Denominator int32
}

SRational is a signed rational value

type Tag

type Tag struct {
	ValueOffset uint32 // 4 bytes
	UnitCount   uint32 // 4 bytes
	ID          ID     // 2 bytes

	Ifd uint8 // 1 byte
	// contains filtered or unexported fields
}

Tag is an Exif Tag

func NewTag

func NewTag(tagID ID, tagType Type, unitCount uint32, valueOffset uint32, ifd uint8) (Tag, error)

NewTag returns a new Tag from tagID, tagType, unitCount, valueOffset and rawValueOffset. If tagType is Invalid returns ErrTagTypeNotValid

func (Tag) IsEmbedded

func (t Tag) IsEmbedded() bool

IsEmbedded checks if the Tag's value is embedded in the Tag.ValueOffset

func (Tag) IsIfd

func (t Tag) IsIfd() bool

IsIfd checks if the Tag's value is an IFD

func (Tag) IsType

func (t Tag) IsType(ty Type) bool

IsType returns true if tagType matches query Type

func (Tag) Size

func (t Tag) Size() uint32

Size returns the size of the Tag's value

func (Tag) String

func (t Tag) String() string

func (Tag) Type

func (t Tag) Type() Type

Type returns the type of Tag

type Type

type Type uint8

Type is the type of Tag

const (
	TypeUnknown Type = 0
	// TypeByte describes an encoded list of bytes.
	TypeByte Type = 1

	// TypeASCII describes an encoded list of characters that is terminated
	// with a NUL in its encoded form.
	TypeASCII Type = 2

	// TypeShort describes an encoded list of shorts.
	TypeShort Type = 3

	// TypeLong describes an encoded list of longs.
	TypeLong Type = 4

	// TypeRational describes an encoded list of rationals.
	TypeRational Type = 5

	// TypeUndefined describes an encoded value that has a complex/non-clearcut
	// interpretation.
	TypeUndefined Type = 7

	// TypeSignedShort describes an encoded list of signed shorts. (experimental)
	TypeSignedShort Type = 8

	// TypeSignedLong describes an encoded list of signed longs.
	TypeSignedLong Type = 9

	// TypeSignedRational describes an encoded list of signed rationals.
	TypeSignedRational Type = 10

	// TypeASCIINoNul is just a pseudo-type, for our own purposes.
	TypeASCIINoNul Type = 0xf0

	// TypeIfd is a pseudo-type, for our own purposes.
	TypeIfd Type = 0xf1
)

TagTypes defined Copied from dsoprea/go-exif

func (Type) Is

func (tt Type) Is(t Type) bool

Is returns true if tagType matches query Type

func (Type) IsValid

func (tt Type) IsValid() bool

IsValid returns true if tagType is a valid type.

func (Type) Size

func (tt Type) Size() uint8

Size returns the size of one atomic unit of the type.

func (Type) String

func (tt Type) String() string

String returns the name of the Tag Type

Jump to

Keyboard shortcuts

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