Documentation ¶
Overview ¶
Package metadata parses metadata in media files.
Currently metadata in JPEG (Exif and XMP) and MP4 (XMP) formats are supported.
Index ¶
Constants ¶
const ( // date of original image (eg. scanned photo) DateTimeOriginal = "DateTimeOriginal" // original file creation date (eg. time of scan) DateTimeCreated = "DateTimeCreated" // Date/time of GPS fix (RFC3339, always UTC) GPSDateTime = "GPSDateTime" // latitude and longitude are signed floating point // values formatted with no exponent GPSLatitude = "GPSLatitude" // +north, -south GPSLongitude = "GPSLongitude" // +east, -west // Orientation (integer) 1..8, values are like exif Orientation = "Orientation" // XMP Rating (integer), -1: rejected, 0: unrated, 1..5: user rating Rating = "Rating" // recording equipment manufacturer and model name/number name Make = "Make" Model = "Model" )
Attribute names read from media files.
Date/time values are formatted as expected by the Time type of this package.
Variables ¶
var ErrNoMeta = errors.New("metadata: no metadata found")
ErrNoMeta is returned by Parse and ParseAt when the file format was recognised but no metadata was found.
var ErrUnknownFormat = errors.New("metadata: unknown content format")
ErrUnknownFormat is returned by Parse and ParseAt when the file format is not understood by this package.
var TimeAttrs = setOf(DateTimeOriginal, DateTimeCreated, GPSDateTime)
TimeAttrs lists time attributes recognised in Merge.
Functions ¶
This section is empty.
Types ¶
type GPSInfo ¶
type GPSInfo struct { // Latitude and Longitude are the geographical location. // Positive latitude means north, positive longitude means east. Latitude float64 Longitude float64 // Time is time of the GPS fix. Zero means undefined. Time time.Time }
GPSInfo records GPS information.
type Metadata ¶
type Metadata struct { // Date of original image (eg. scanned photo) DateTimeOriginal Time // Original file creation date (eg. time of scan) DateTimeCreated Time // GPS records GPS information. GPS struct { GPSInfo // Valid indicates if Latitude and Longitude // fields of GPSInfo are valid. Valid bool } // Orientation is the Exif orientation. // Possible values are based on the exif spec: // 0: undefined // 1: no rotation // 2: flip horizontal // 3: rotate 180° // 4: flip vertical // 5: transpose // 6: rotate 90° // 7: transverse // 8: rotate 270° Orientation int // Rating is the XMP rating. Possible values are: // -1: rejected // 0: unrated or missing // 1..5: user rating Rating int // Recording equipment manufacturer and model name/number name Make, Model string // Attr holds metadata attributes as strings. Attr map[string]string }
Metadata records file metadata.
func FromExifBytes ¶
func FromXMPBytes ¶
func Parse ¶
Parse parses metadata from r, and returns the metadata found and the first error encountered.
Metadata is parsed on a best effort basis. Valid values are always returned even when if non-fatal errors had been encountered by decoding the underlying formats.
If r is also an io.Seeker, then it is used to seek within r.
type Time ¶
type Time struct { // Actual time value. // Its location is always time.Local if HasLoc is false. time.Time // Prec records the number of valid components of the parsed // value between 1 (year) and 7 (subsecond). // A Time with Prec == 0 is invalid. Prec int // HasLoc records whether the parsed value included a time zone. HasLoc bool }
Time is like time.Time but records the precision (year, month, day, hour, minute, second or subsecond) of the parsed string and whether a time zone was specified.
Certain metadata formats has limited time representations:
MVHD in MP4 is unix(ish) time lacking time zone information.
Exif has a fixed standard time layout without a time zone. Certain tools can write time zone information to Exif date fields, but such Exif files are technically invalid.
XMP uses the time format understood by ParseTime, but may omit elements from the end of the string, reducing precision.
func ParseTime ¶
ParseTime parses a time string based on the RFC 3339 format, possibly truncated and with or without a time zone.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
example
|
|
Package exif implements an JPEG/Exif decoder and encoder.
|
Package exif implements an JPEG/Exif decoder and encoder. |
exiftag
Package exiftag defines constants used for TIFF and Exif files.
|
Package exiftag defines constants used for TIFF and Exif files. |
Package jpeg implements a low-level a JPEG scanner.
|
Package jpeg implements a low-level a JPEG scanner. |
Package orient provides the Orient function that applies an Exif orientation to an image.
|
Package orient provides the Orient function that applies an Exif orientation to an image. |