tiff

package
v0.0.0-...-49a09c6 Latest Latest
Warning

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

Go to latest
Published: May 20, 2014 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package tiff provides support for decoding the structure of TIFF 6.0 files.

The specification can be found at http://www.exif.org/TIFF6.pdf.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ascii

type Ascii uint8

type Byte

type Byte uint8

type ByteOrder

type ByteOrder struct {
	binary.ByteOrder
}

A ByteOrder represents the byte order of a TIFF file and supports decoding of the various TIFF types.

func (ByteOrder) Long

func (order ByteOrder) Long(b []byte) Long

Read and decode 4 bytes as Long

func (ByteOrder) Offset

func (order ByteOrder) Offset(b []byte) int64

Read a 4-byte file offset

func (ByteOrder) Rational

func (order ByteOrder) Rational(b []byte) (r Rational)

Read and decode 2x 2-bytes as a Rational

func (ByteOrder) ReadIFD

func (order ByteOrder) ReadIFD(r io.ReaderAt, offset int64) *IFD

func (ByteOrder) Short

func (order ByteOrder) Short(b []byte) Short

Read and decode 2 bytes as Short

func (ByteOrder) Slong

func (order ByteOrder) Slong(b []byte) Slong

func (ByteOrder) Srational

func (order ByteOrder) Srational(b []byte) (r Srational)

Read and decode 2x 2-byte as a Srational

type Double

type Double float64

type Entry

type Entry struct {
	Offset int64    // Offset of this Entry within its associated ReaderAt
	Tag    TagID    // Tag code
	Type   TagType  // Tag type
	Count  TagCount // How many elements of type Type are covered by this Entry
	Value  TagValue // Value or offset to value if it doesn't fit in 4 bytes
}

An Entry contains the data for a single entry or field in an IFD (Image Field Directory).

func (Entry) ValueByteSize

func (e Entry) ValueByteSize() int64

ValueByteSize returns the total byte size of e.Entry's Value.

func (Entry) ValueIsOffset

func (e Entry) ValueIsOffset() bool

Returns true if e.Value is an offset to where the value data can be found.

type File

type File struct {
	*Header
	io.ReaderAt
	IFD *IFD
}

A File represents a decoded TIFF file.

func Read

func Read(r io.ReaderAt) (*File, error)

Read attempts to decode the provided io.ReaderAt according to the TIFF spec.

func (File) Bytes

func (f File) Bytes(e Entry) ([]byte, error)

Bytes returns the Value bytes pointed to by a particular entry.

func (File) EntryReader

func (f File) EntryReader(e Entry) io.ReaderAt

EntryReader returns a ReaderAt which can be used to extract the bytes associated with an Entry.

func (File) ReadIFD

func (f File) ReadIFD(offset int64) *IFD

ReadIFD decodes the IFD structure of the File recursively until no more IFD's can be found.

type Float

type Float float32
type Header struct {
	ByteOrder
	FirstIFD int64 // Offset to first IFD
}

Header represents a TIFF file header.

type IFD

type IFD struct {
	Offset  int64
	Entries []Entry
	Next    *IFD
}

IFD describes the contents of an Image File Directory entry in a TIFF file.

type Long

type Long uint32

type Rational

type Rational struct {
	Numer, Denom Long
}

func (Rational) String

func (r Rational) String() string

type Sbyte

type Sbyte int8

type Short

type Short uint16

type Slong

type Slong int32

type Srational

type Srational struct {
	Numer, Denom Slong
}

func (Srational) String

func (r Srational) String() string

type Sshort

type Sshort int16

type TagCount

type TagCount uint32

A TagCount describes how many repeated elements there are of e.Type in this Entry.

type TagID

type TagID uint16

A TagID represents the 16 bit integer identifier for an IFD tag.

func (TagID) GoString

func (c TagID) GoString() string

Returns the TagID integer value encoded as a hexadecimal.

func (TagID) Lookup

func (c TagID) Lookup(spaces ...TagSpace) string

Return the first name assocated with the TagID in the given TagSpace(s).

func (TagID) String

func (c TagID) String() string

Returns the TagID name as defined in BaseLine, Extension, Private, Exif, and Gps TagSpaces.

type TagSpace

type TagSpace struct {
	// contains filtered or unexported fields
}

A TagSpace represents a (named) collection of TIFF tags.

var BaseLine TagSpace = CreateTagSpace("BaseLine")
var Exif TagSpace = CreateTagSpace("Exif")
var Extension TagSpace = CreateTagSpace("Extension")
var Gps TagSpace = CreateTagSpace("Gps")
var Private TagSpace = CreateTagSpace("Private")

func CreateTagSpace

func CreateTagSpace(name string) TagSpace

CreateTagSpace returns a new TagSpace labelled name.

func (TagSpace) GetCode

func (ns TagSpace) GetCode(name string) (TagID, error)

func (TagSpace) GetName

func (ns TagSpace) GetName(c TagID) (string, error)

func (TagSpace) HasCode

func (ns TagSpace) HasCode(c TagID) bool

Returns true if c is in ns.

func (TagSpace) HasName

func (ns TagSpace) HasName(name string) bool

func (TagSpace) Set

func (ns TagSpace) Set(code TagID, name string)

Set associates code and name in the TagSpace ns.

type TagType

type TagType uint16

A TagType represents the 16 bit code for the different tag types defined by the TIFF spec.

const (
	BYTE TagType = iota
	ASCII
	SHORT
	LONG
	RATIONAL
	SBYTE
	UNDEFINED
	SSHORT
	SLONG
	SRATIONAL
	FLOAT
	DOUBLE
	IFDPTR
)

func (TagType) ByteSize

func (t TagType) ByteSize() int64

func (TagType) String

func (t TagType) String() string

type TagValue

type TagValue [4]byte

A TagValue contains the direct value stored in each TIFF entry.

type Undefined

type Undefined uint8

Jump to

Keyboard shortcuts

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