tiff

package
v0.0.0-...-2f1a4f0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2014 License: Apache-2.0, BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package tiff implements TIFF decoding as defined in TIFF 6.0 specification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir struct {
	Tags []*Tag
}

Dir reflects the parsed content of a tiff Image File Directory (IFD).

func DecodeDir

func DecodeDir(r ReadAtReader, order binary.ByteOrder) (d *Dir, offset int32, err error)

DecodeDir parses a tiff-encoded IFD from r and returns a Dir object. offset is the offset to the next IFD. The first read from r should be at the first byte of the IFD. ReadAt offsets should be relative to the beginning of the tiff structure (not relative to the beginning of the IFD).

func (*Dir) String

func (d *Dir) String() string

type FormatType

type FormatType int
const (
	IntVal FormatType = iota
	FloatVal
	RatVal
	StringVal
	UndefVal
	OtherVal
)

type ReadAtReader

type ReadAtReader interface {
	io.Reader
	io.ReaderAt
}

ReadAtReader is used when decoding Tiff tags and directories

type Tag

type Tag struct {
	// Id is the 2-byte tiff tag identifier
	Id uint16
	// Fmt is an integer (1 through 12) indicating the tag value's format.
	Fmt uint16
	// Ncomp is the number of type Fmt stored in the tag's value (i.e. the tag's
	// value is an array of type Fmt and length Ncomp).
	Ncomp uint32
	// Val holds the bytes that represent the tag's value.
	Val []byte
	// contains filtered or unexported fields
}

Tag reflects the parsed content of a tiff IFD tag.

func DecodeTag

func DecodeTag(r ReadAtReader, order binary.ByteOrder) (*Tag, error)

DecodeTag parses a tiff-encoded IFD tag from r and returns Tag object. The first read from r should be the first byte of the tag. ReadAt offsets should be relative to the beginning of the tiff structure (not relative to the beginning of the tag).

func (*Tag) Float

func (t *Tag) Float(i int) float64

Float returns the tag's i'th value as a float. It panics if the tag format is not FloatVal or if the tag value has no i'th component.

func (*Tag) Format

func (t *Tag) Format() FormatType

Format returns a value indicating which method can be called to retrieve the tag's value properly typed (e.g. integer, rational, etc.).

func (*Tag) Int

func (t *Tag) Int(i int) int64

Int returns the tag's i'th value as an integer. It panics if the tag format is not IntVal or if the tag value has no i'th component.

func (*Tag) MarshalJSON

func (t *Tag) MarshalJSON() ([]byte, error)

func (*Tag) Rat

func (t *Tag) Rat(i int) *big.Rat

Rat returns the tag's i'th value as a rational number. It panics if the tag format is not RatVal, if the denominator is zero, or if the tag has no i'th component. If a denominator could be zero, use Rat2.

func (*Tag) Rat2

func (t *Tag) Rat2(i int) (num, den int64)

Rat2 returns the tag's i'th value as a rational number represented by a numerator-denominator pair. It panics if the tag format is not RatVal or if the tag value has no i'th component.

func (*Tag) String

func (t *Tag) String() string

String returns a nicely formatted version of the tag.

func (*Tag) StringVal

func (t *Tag) StringVal() string

StringVal returns the tag's value as a string. It panics if the tag format is not StringVal

type Tiff

type Tiff struct {
	// Dirs is an ordered slice of the tiff's Image File Directories (IFDs).
	// The IFD at index 0 is IFD0.
	Dirs []*Dir
	// The tiff's byte-encoding (i.e. big/little endian).
	Order binary.ByteOrder
}

Tiff provides access to decoded tiff data.

func Decode

func Decode(r io.Reader) (*Tiff, error)

Decode parses tiff-encoded data from r and returns a Tiff that reflects the structure and content of the tiff data. The first read from r should be the first byte of the tiff-encoded data (not necessarily the first byte of an os.File object).

func (*Tiff) String

func (tf *Tiff) String() string

Jump to

Keyboard shortcuts

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