iptc

package module
v0.0.0-...-bc9ca20 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 10 Imported by: 11

README

Build Status Coverage Status Go Report Card GoDoc

Overview

This project provides functionality to parse a series of IPTC records/datasets. It also provides name resolution, but other constraints/validation is not yet implemented (though there is structure present that can accommodate this when desired/required).

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTagMarker indicates that the tag can not be parsed because the
	// tag boundary marker is not the expected value.
	ErrInvalidTagMarker = errors.New("invalid tag marker")
)
View Source
var (
	// ErrTagNotStandard indicates that the given tag is not known among the
	// documented standard set.
	ErrTagNotStandard = errors.New("not a standard tag")
)

Functions

func DumpBytesToString

func DumpBytesToString(data []byte) string

DumpBytesToString returns a stringified list of hex-encoded bytes.

func GetDictionaryFromParsedTags

func GetDictionaryFromParsedTags(pt ParsedTags) (distilled map[string]string)

GetDictionaryFromParsedTags returns all tags. It will keep non-printable values, though will not print a placeholder instead. This will keep non- standard tags (and print the fully-qualified dataset ID rather than the name). It will keep repeated values (with the counter value appended to the end).

func GetModuleRootPath

func GetModuleRootPath() string

GetModuleRootPath returns the root-path of the module.

func GetSimpleDictionaryFromParsedTags

func GetSimpleDictionaryFromParsedTags(pt ParsedTags) (distilled map[string]string)

GetSimpleDictionaryFromParsedTags returns a dictionary of tag names to tag values, where all values are strings and any tag that had a non-printable value is omitted. We will also only return the first value, therefore dropping any follow-up values for repeatable tags. This will ignore non- standard tags. This will trim whitespace from the ends of strings.

This is a convenience function for quickly displaying only the summary IPTC metadata that a user might actually be interested in at first glance.

func GetTestAssetsPath

func GetTestAssetsPath() string

GetTestAssetsPath returns the path of the test-assets.

func GetTestDataFilepath

func GetTestDataFilepath() string

GetTestDataFilepath returns the file-path of the common test-data.

func ParseStream

func ParseStream(r io.Reader) (tags map[StreamTagKey][]TagData, err error)

ParseStream parses a serial sequence of tags and tag data out of the stream.

Types

type ParsedTags

type ParsedTags map[StreamTagKey][]TagData

ParsedTags is the complete, unordered set of tags parsed from the stream.

type StreamTagInfo

type StreamTagInfo struct {
	// Description is the human-readable description of the tag.
	Description string
}

StreamTagInfo encapsulates the properties of each tag.

func GetTagInfo

func GetTagInfo(recordNumber, datasetNumber int) (sti StreamTagInfo, err error)

GetTagInfo return the info for the given tag. Returns ErrTagNotStandard if not known.

type StreamTagKey

type StreamTagKey struct {
	// RecordNumber is the major classification of the dataset.
	RecordNumber uint8

	// DatasetNumber is the minor classification of the dataset.
	DatasetNumber uint8
}

StreamTagKey is a convenience type that lets us key our index with a high- level type.

func (StreamTagKey) String

func (stk StreamTagKey) String() string

String returns a descriptive string.

type Tag

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

Tag describes one tag read from the stream.

func DecodeTag

func DecodeTag(r io.Reader) (tag Tag, err error)

DecodeTag parses one tag from the stream.

func (*Tag) String

func (tag *Tag) String() string

String expresses state as a string.

type TagData

type TagData []byte

TagData is a convenience wrapper around a byte-slice.

func (TagData) IsPrintable

func (tg TagData) IsPrintable() bool

IsPrintable returns true if all characters are printable.

func (TagData) String

func (tg TagData) String() string

String returns a descriptive string. If the data doesn't include any non- printable characters, it will include the value itself.

Jump to

Keyboard shortcuts

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