2.0.0 • Published 3 years ago
png-chunks-extractor v2.0.0
Basic PNG chunks extractor
Installation
png-chunks-extractor is a Node.js module. It is available as a npm package.
npm i png-chunks-extractorExample
The package supports both ESM import and CJS require.
import chunksExtractor from 'png-chunks-extractor';
const {chunks, chunksByType} = await chunksExtractor('path/to/file');chunks is an array of PNG chunks data and type.
{
dataBuf: <Buffer 00 00 03 00 00 00 03 00 08 02 00 00 00>,
type: 1229472850 // 'IHDR' decimal value
}Documentation
chunksExtractor(PNGFile, options)
PNGFile\ | \ The file to parse.options\validateStruct\ Enables PNG structure validation. Default:truevalidateCrc\ Enables Chunks CRC validation. CRC validation impacts parsing time. Default:falsethrowOnError\ Throws an error whenever there is a validation error. Default:falselogOnError\ Logs any validation error. Default:true
- Returns \ | \ If the general structure validation fails
chunks\<Object[]> An array of the PNG chunks.type\<uint 32> The latin1 decimal expression of the typedataBuf\ Raw chunk data
chunksByType\ An object with PNG type keys and chunk objects values
Parses PNGFile and returns its chunks