JPEG decoding for Node.js, using libjpeg-turbo compiled to WebAssembly.
npm install --save @cwasm/jpeg-turbo
const fs = require('fs')
const jpeg = require('@cwasm/jpeg-turbo')
const source = fs.readFileSync('image.jpg')
const image = jpeg.decode(source)
console.log(image)
// { width: 128,
// height: 128,
// data:
// Uint8ClampedArray [ ... ] }
decode(source)
source
(Uint8Array
, required) - The JPEG dataImageData
- Decoded width, height and pixel data