Documentation ¶
Index ¶
- type IndexedTag
- type IndexedValue
- type SearchResult
- type TreeIndex
- func (ti *TreeIndex) AddPath(rootPath string) (err error)
- func (ti *TreeIndex) AddTree(rootPath string) (err error)
- func (ti *TreeIndex) AddedFiles() (files []string)
- func (ti *TreeIndex) GetFirstIfdMatches(tagName string) []IndexedValue
- func (ti *TreeIndex) Index() map[IndexedTag][]IndexedValue
- func (ti *TreeIndex) Search(query string, tagNames []string) (hits []SearchResult, err error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IndexedTag ¶
type IndexedTag struct { // IfdPath is the name of the IFD path at which the tag was found. IfdPath string // TagId is the ID of the tag. TagId uint16 // TagName is the name of the tag. TagName string }
IndexedTag uniquely describes a particular tag.
func (IndexedTag) String ¶
func (it IndexedTag) String() string
String returns a string representation of the IndexedTag.
type IndexedValue ¶
type IndexedValue struct { // Filepath is the fully-qualified path of this file. Filepath string // ValuePhrase is the stringified value of the tag for this file. ValuePhrase string }
IndexedValue is the value for a particular tag in a particular file.
func (IndexedValue) String ¶
func (iv IndexedValue) String() string
String returns a string representation of the IndexedValue.
type SearchResult ¶
SearchResult represents a single hit.
func (SearchResult) String ¶
func (sr SearchResult) String() string
String returns a stringified representation of the result.
type TreeIndex ¶
type TreeIndex struct {
// contains filtered or unexported fields
}
TreeIndex is an index of the tags of many files.
func (*TreeIndex) AddedFiles ¶
AddedFiles returns a list of the files that have been parsed.
func (*TreeIndex) GetFirstIfdMatches ¶
func (ti *TreeIndex) GetFirstIfdMatches(tagName string) []IndexedValue
GetFirstIfdMatches returns the files and values for the given tag in the first IFD it was found for. Often, if a tag is presentfor both IFD0/IFD1 and the Exif IFD, it will just be duplicated. So, we're just providing a convenience function to bypass the obligatory consideration of which, when a) people won't generally know which IFD a tag *should* be in, and they wouldn't have a preference or even care.
Note that if a particular IFD or looking-up using a tag-ID rather than a name is desired, the indexed should be referenced directly.
This method merely returns an empty list if the given tag wasn't found in any indexed file.
Example ¶
ti := NewTreeIndex() assetsPath := exifextracommon.GetTestAssetsPath() err := ti.AddPath(assetsPath) log.PanicIf(err) values := ti.GetFirstIfdMatches("Software") byFilename := make(map[string]string) for _, value := range values { byFilename[filepath.Base(value.Filepath)] = value.ValuePhrase } for _, filename := range []string{"image.tiff", "image.webp"} { fmt.Printf("%s: %s\n", filename, byFilename[filename]) }
Output: image.tiff: Mac OS X 10.5.8 (9L31a) image.webp: GIMP 2.10.24
func (*TreeIndex) Index ¶
func (ti *TreeIndex) Index() map[IndexedTag][]IndexedValue
Index is the currently-loaded index.
func (*TreeIndex) Search ¶
func (ti *TreeIndex) Search(query string, tagNames []string) (hits []SearchResult, err error)
Search does a case-insensitive search through the values of the given tags acros all indexed files. If no tags are given, all tags will be searched. The tag-names are also case-insensitive.
Example ¶
ti := NewTreeIndex() assetsPath := exifextracommon.GetTestAssetsPath() err := ti.AddPath(assetsPath) log.PanicIf(err) hits, err := ti.Search("GIMP", nil) log.PanicIf(err) sr := hits[0] fmt.Printf("File: %s\n", filepath.Base(sr.Filepath)) fmt.Printf("IfdPath: %s\n", sr.IfdPath) fmt.Printf("TagName: %s\n", sr.TagName) fmt.Printf("Value: %s\n", sr.ValuePhrase)
Output: File: image.webp IfdPath: IFD TagName: Software Value: GIMP 2.10.24