Documentation ¶
Overview ¶
Package pngtext provides function ParseTextualData that parses a PNG file and returns a list of textual data stored in the file.
To parse textual data, simply call ParseTextualData:
r, _ := os.Open("test.png") defer r.Close() res, _ := pngtext.ParseTextualData(r)
TextualDataList, which ParseTextualData returns as a result, is a list of TextualData but also implements Find function that helps you to get text data associated with a keyword. This returns TextualData of which keyword is Description:
res.Find("Description")
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type TextualData ¶
type TextualData struct { // Keyword of the textual data. Keyword string // Text string associated with the keyword Text string // LanguageTag indicates the human language used by the translated keyword and the text. // Only iTXt chunk has this attribute. LanguageTag string // TranslatedKeyword is a translation of the keyword into the language indicated by the language tag. // Only iTXt chunk has this attribute. TranslatedKeyword string }
TextualData defines attributes one chunk could have. See also: https://www.w3.org/TR/2003/REC-PNG-20031110/#11textinfo
type TextualDataList ¶
type TextualDataList []*TextualData
TextualDataList is a list of *TextualData that provides Find and implements sort.Interface.
func ParseTextualData ¶
func ParseTextualData(r io.Reader) (TextualDataList, error)
ParseTextualData reads PNG data from the given reader and parses textual data.
Example ¶
r, _ := os.Open("test.png") defer r.Close() res, _ := pngtext.ParseTextualData(r) fmt.Println(res.Find("Text").Text)
Output: text data
func (TextualDataList) Find ¶
func (list TextualDataList) Find(keyword string) *TextualData
Find sequentially searches an item of which keyword matches the given one. Returns nil if not matches any item.
func (TextualDataList) Len ¶
func (list TextualDataList) Len() int
Len is the number of elements in the collection.
func (TextualDataList) Less ¶
func (list TextualDataList) Less(i, j int) bool
Less reports whether the element with index i must sort before the element with index j.
func (TextualDataList) Swap ¶
func (list TextualDataList) Swap(i, j int)
Swap swaps the elements with indexes i and j.