2.0.0 • Published 1 year 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-extractor
Example
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:true
validateCrc
\ Enables Chunks CRC validation. CRC validation impacts parsing time. Default:false
throwOnError
\ Throws an error whenever there is a validation error. Default:false
logOnError
\ 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