@fiahfy/packbits
v0.0.6
Published
PackBits implementation in JavaScript
Downloads
4,231
Readme
packbits
PackBits implementation in JavaScript.
Installation
npm install @fiahfy/packbits
Usage
Default
Encoding
import { encode } from '@fiahfy/packbits'
console.log(buf) // <Buffer aa bb bb cc cc cc dd dd dd dd>
const encoded = encode(buf)
console.log(encoded) // <Buffer 00 aa ff bb fe cc fd dd>
Decoding
import { decode } from '@fiahfy/packbits'
console.log(buf) // <Buffer 00 aa ff bb fe cc fd dd>
const decoded = decode(buf)
console.log(decoded) // <Buffer aa bb bb cc cc cc dd dd dd dd>
ICNS format
In Apple Icon Image format, pixel data are often compressed (per channel) with a format similar to PackBits.
Encoding
import { encode } from '@fiahfy/packbits'
console.log(buf) // <Buffer aa bb bb cc cc cc dd dd dd dd>
const encoded = encode(buf, { format: 'icns' })
console.log(encoded) // <Buffer 02 aa bb bb 80 cc 81 dd>
Decoding
import { decode } from '@fiahfy/packbits'
console.log(buf) // <Buffer 02 aa bb bb 80 cc 81 dd>
const decoded = decode(buf, { format: 'icns' })
console.log(decoded) // <Buffer aa bb bb cc cc cc dd dd dd dd>