png-chunk-text
Create or parse a PNG tEXt chunk for storing uncompressed text data in PNG images.
Can be used in combination with png-chunks-extract and png-chunks-encode for adding and reading custom metadata in PNG images.
Works in Node, or in the browser using browserify.
Usage
chunk = text.encode(key, value)
Returns a chunk object containing the metadata for a given key
and value
:
name: 'tEXt'data: Uint8Array...
const extract =const encode =const text =const path =const fs =const buffer = fsconst chunks =// Add new chunks before the IEND chunkchunkschunksfs
data = text.decode(chunk)
Reads a Uint8Array
or Node.js Buffer
instance containing a tEXt
PNG chunk's data and returns its keyword/text:
keyword: 'hello'text: 'world'
const extract =const text =const path =const fs =const buffer = fsconst chunks =const textChunks = chunksconsole // 'hello'console // 'world'console // 'lorem'console // 'ipsum'
See Also
License
MIT, see LICENSE.md for details.