Documentation ¶
Overview ¶
Package tiff implements structures and functionality for working with TIFF data structures.
References:
[TIFF6]: http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf [TIFFPM6]: http://partners.adobe.com/public/developer/en/tiff/TIFFPM6.pdf [TIFFTAGS]: http://www.digitalpreservation.gov/formats/content/tiff_tags.shtml
Index ¶
- Constants
- Variables
- func GetByteOrder(bo uint16) binary.ByteOrder
- func GetTiffFieldPrintFullFieldValue() bool
- func ListTagSpaceNames() []string
- func ParseTiffFieldStructTag(text string) (out *fieldStructTag)
- func ParseTiffIFDStructTag(text string) *ifdStructTag
- func ParseTiffStructTag(text string) *tiffStructTag
- func ParseTiffSubIFDStructTag(text string) *subIFDStructTag
- func RegisterFieldTypeSet(fts FieldTypeSet)
- func RegisterFieldTypeSpace(ftsp FieldTypeSpace)
- func RegisterTagSet(ts TagSet)
- func RegisterTagSpace(tsp TagSpace)
- func RegisterVersion(v uint16, tp TIFFParser)
- func SetTiffFieldPrintFullFieldValue(b bool)
- func UnmarshalIFD(ifd IFD, out interface{}) error
- func UnmarshalSubIFDs(ifd IFD, br BReader, tsp TagSpace, out interface{}) error
- func UnmarshalTIFF(t TIFF, out interface{}) error
- type BReader
- type Entry
- type ErrInvalidByteOrder
- type ErrUnsuppConversion
- type ErrUnsuppStructField
- type ErrUnsuppTIFFVersion
- type Field
- type FieldInterpreter
- type FieldParser
- type FieldType
- type FieldTypeRepr
- type FieldTypeSet
- type FieldTypeSpace
- type FieldTypeValuer
- type FieldValue
- type Header
- type IFD
- type IFDParser
- type ReadAtReadSeeker
- type TIFF
- type TIFFParser
- type Tag
- type TagSet
- type TagSpace
Constants ¶
const ( MagicBigEndian = "MM\x00\x2A" MagicLitEndian = "II\x2A\x00" Version uint16 = 0x2A VersionName string = "TIFF" )
These constants represents the first 4 bytes of the file for each kind of TIFF along with each byte ordering. This is mostly useful for registration with the "image" package from the Go standard library.
const ( BigEndian uint16 = 0x4D4D // "MM" or 19789 LitEndian uint16 = 0x4949 // "II" or 18761 )
These constants represent the byte order options present at the beginning of a TIFF file.
Variables ¶
var ( FTByte = NewFieldType(1, "Byte", 1, false, reprByte, rvalByte, typByte) FTAscii = NewFieldType(2, "ASCII", 1, false, reprASCII, rvalASCII, typString) FTShort = NewFieldType(3, "Short", 2, false, reprShort, rvalShort, typU16) FTLong = NewFieldType(4, "Long", 4, false, reprLong, rvalLong, typU32) FTRational = NewFieldType(5, "Rational", 8, false, reprRational, rvalRational, typBigRat) FTSByte = NewFieldType(6, "SByte", 1, true, reprSByte, rvalSByte, typI8) FTUndefined = NewFieldType(7, "Undefined", 1, false, reprByte, rvalByte, typByte) FTSShort = NewFieldType(8, "SShort", 2, true, reprSShort, rvalSShort, typI16) FTSLong = NewFieldType(9, "SLong", 4, true, reprSLong, rvalSLong, typI32) FTSRational = NewFieldType(10, "SRational", 8, true, reprSRational, rvalSRational, typBigRat) FTFloat = NewFieldType(11, "Float", 4, true, reprFloat, rvalFloat, typF32) FTDouble = NewFieldType(12, "Double", 8, true, reprDouble, rvalDouble, typF64) FTIFD = NewFieldType(13, "IFD", 4, false, reprLong, rvalLong, typU32) // TODO: These two are not complete. Get the details and finish them. FTUnicode = NewFieldType(14, "Unicode", 2, false, reprByte, rvalByte, typByte) FTComplex = NewFieldType(15, "Complex", 8, true, reprByte, rvalByte, typByte) )
Default set of Field types. These are exported for others to use in registering custom tags.
var BaselineTags = NewTagSet("Baseline", 1, 64999)
var DefaultFieldTypeSet = NewFieldTypeSet("Default")
DefaultFieldTypeSet is the default set of field types supported by this package. A user is free to create their own FieldTypeSet from which to support extended functionality or to provide a substitute representation for known types. Most users will be fine with the default set defined here.
var DefaultFieldTypeSpace = NewFieldTypeSpace("Default")
var DefaultTagSpace = NewTagSpace("Default")
var ExtendedTags = NewTagSet("Extended", 1, 64999)
var PrivateTags = NewTagSet("Private", 32768, 65535)
Functions ¶
func GetByteOrder ¶
func GetTiffFieldPrintFullFieldValue ¶
func GetTiffFieldPrintFullFieldValue() bool
func ListTagSpaceNames ¶
func ListTagSpaceNames() []string
func ParseTiffFieldStructTag ¶
func ParseTiffFieldStructTag(text string) (out *fieldStructTag)
func ParseTiffIFDStructTag ¶
func ParseTiffIFDStructTag(text string) *ifdStructTag
func ParseTiffStructTag ¶
func ParseTiffStructTag(text string) *tiffStructTag
func ParseTiffSubIFDStructTag ¶
func ParseTiffSubIFDStructTag(text string) *subIFDStructTag
func RegisterFieldTypeSet ¶
func RegisterFieldTypeSet(fts FieldTypeSet)
RegisterFieldTypeSet registers a FieldTypeSet in the DefaultFieldTypeSpace. Only FieldTypes that would not cause collisions should be registered this way.
func RegisterFieldTypeSpace ¶
func RegisterFieldTypeSpace(ftsp FieldTypeSpace)
func RegisterTagSet ¶
func RegisterTagSet(ts TagSet)
RegisterTagSet registers a TagSet in the DefaultTagSpace. Only tags that would not cause collisions should be registered this way (i.e. GPS and MakerNote tags would cause collisions with the default tiff tag space.)
func RegisterTagSpace ¶
func RegisterTagSpace(tsp TagSpace)
func RegisterVersion ¶
func RegisterVersion(v uint16, tp TIFFParser)
func SetTiffFieldPrintFullFieldValue ¶
func SetTiffFieldPrintFullFieldValue(b bool)
func UnmarshalIFD ¶
func UnmarshalSubIFDs ¶
func UnmarshalTIFF ¶
Types ¶
type BReader ¶
type BReader interface { BRead(data interface{}) error BReadSection(data interface{}, offset int64, n int64) error ByteOrder() binary.ByteOrder ReadAtReadSeeker }
BReader wraps a ReadAtReadSeeker with a specific binary.ByteOrder.
func NewBReader ¶
func NewBReader(r ReadAtReadSeeker, o binary.ByteOrder) BReader
type Entry ¶
Entry represents a single entry in an IFD in a TIFF file. This is the mostly uninterpreted core 12 byte data structure only.
func ParseEntry ¶
type ErrInvalidByteOrder ¶
type ErrInvalidByteOrder struct {
Order [2]byte
}
func (ErrInvalidByteOrder) Error ¶
func (e ErrInvalidByteOrder) Error() string
type ErrUnsuppConversion ¶
func (ErrUnsuppConversion) Error ¶
func (e ErrUnsuppConversion) Error() string
type ErrUnsuppStructField ¶
func (ErrUnsuppStructField) Error ¶
func (e ErrUnsuppStructField) Error() string
type ErrUnsuppTIFFVersion ¶
type ErrUnsuppTIFFVersion struct {
Version uint16
}
func (ErrUnsuppTIFFVersion) Error ¶
func (e ErrUnsuppTIFFVersion) Error() string
type Field ¶
type Field interface { Tag() Tag Type() FieldType Count() uint64 Offset() uint64 Value() FieldValue // TODO: Change to BReader?? }
Field represents a field in an IFD in a TIFF file.
func ParseField ¶
func ParseField(br BReader, tsp TagSpace, ftsp FieldTypeSpace) (out Field, err error)
type FieldInterpreter ¶
type FieldParser ¶
type FieldParser func(BReader, TagSpace, FieldTypeSpace) (Field, error)
type FieldType ¶
type FieldType interface { ID() uint16 Name() string Size() uint64 Signed() bool ReflectType() reflect.Type Repr() FieldTypeRepr Valuer() FieldTypeValuer }
A FieldType represents all of the necessary pieces of information one needs to know about a field type including a function that knows how to represent that type of data in an often human readable string. Other string representation formats could be implemented (json, xml, etc). Field types themselves have no actual stored value inside a TIFF. They are here to help an implementer or user understand their format.
func NewFieldType ¶
func NewFieldType(id uint16, name string, size uint64, signed bool, repr FieldTypeRepr, rval FieldTypeValuer, typ reflect.Type) FieldType
type FieldTypeSet ¶
type FieldTypeSet interface { GetFieldType(id uint16) (FieldType, bool) ListFieldTypes() []uint16 ListFieldTypeNames() []string Name() string Register(ft FieldType) bool Lock() }
FieldTypeSet represents a set of field types that may be in use within a file that uses a TIFF file structure. This can be customized for custom file formats and private IFDs.
func NewFieldTypeSet ¶
func NewFieldTypeSet(name string) FieldTypeSet
type FieldTypeSpace ¶
type FieldTypeSpace interface { Name() string GetFieldType(id uint16) FieldType GetFieldTypeSet(name string) (FieldTypeSet, bool) ListFieldTypeSets() []string RegisterFieldTypeSet(fts FieldTypeSet) }
A FieldTypeSpace represents a group of FieldTypeSets where each of the FieldTypes from one FieldTypeSet should not collide with any of the FieldTypes from another FieldTypeSet.
func GetFieldTypeSpace ¶
func GetFieldTypeSpace(name string) FieldTypeSpace
func NewFieldTypeSpace ¶
func NewFieldTypeSpace(name string) FieldTypeSpace
type FieldValue ¶
type IFD ¶
type IFD interface { NumEntries() uint64 Fields() []Field NextOffset() uint64 HasField(tagID uint16) bool GetField(tagID uint16) Field }
IFD represents the data structure of an IFD in a TIFF File.
type ReadAtReadSeeker ¶
type ReadAtReadSeeker interface { io.ReadSeeker io.ReaderAt }
ReadAtReadSeeker is the interface that wraps the Read, ReadAt, and Seek methods. Typical use cases would satisfy this with a bytes.Reader (in memory) or an os.File (on disk). For truly large files, such as BigTIFF, a user may want to create a custom solution that combines both in memory and on disk solutions for accessing the contents.
func NewReadAtReadSeeker ¶
func NewReadAtReadSeeker(r io.Reader) ReadAtReadSeeker
NewReadAtReadSeeker converts r (an io.Reader) into a ReadAtReadSeeker. If the underlying type of r can satisfy a ReadAtReadSeeker, it is asserted as such and used directly instead of being wrapped.
type TIFF ¶
func Parse ¶
func Parse(r ReadAtReadSeeker, tsp TagSpace, ftsp FieldTypeSpace) (TIFF, error)
type TIFFParser ¶
type TIFFParser func(ordr [2]byte, vers uint16, br BReader, tsp TagSpace, ftsp FieldTypeSpace) (TIFF, error)
func GetVersionParser ¶
func GetVersionParser(v uint16) TIFFParser
type Tag ¶
type Tag interface { ID() uint16 Name() string Interpreter() FieldInterpreter }
type TagSet ¶
type TagSpace ¶
type TagSpace interface { Name() string GetTag(id uint16) Tag GetTagSet(name string) (TagSet, bool) GetTagSetNameFromTag(id uint16) string ListTagSets() []string RegisterTagSet(ts TagSet) }
A TagSpace represents a group of TagSet where each of the tags from one TagSet should not collide with any of the tags from another TagSet.
func GetTagSpace ¶
func NewTagSpace ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package bigtiff implements structures and functionality for working with BigTIFF data structures.
|
Package bigtiff implements structures and functionality for working with BigTIFF data structures. |
References: [GEOTIFF]: http://www.remotesensing.org/geotiff/spec/geotiffhome.html [INTERGRAPH]: http://www.awaresystems.be/imaging/tiff/tifftags/docs/intergraph.html
|
References: [GEOTIFF]: http://www.remotesensing.org/geotiff/spec/geotiffhome.html [INTERGRAPH]: http://www.awaresystems.be/imaging/tiff/tifftags/docs/intergraph.html |
Package modi provides tiff extensions for working with Microsoft Office Document Imaging based tiff files.
|
Package modi provides tiff extensions for working with Microsoft Office Document Imaging based tiff files. |
Package tiff85 provides parsing for a tiff file with a version number of 85.
|
Package tiff85 provides parsing for a tiff file with a version number of 85. |