You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
374 B
22 lines
374 B
// decode jpeg buffer
|
|
'use strict'
|
|
|
|
var jpeg = require('jpeg-js')
|
|
var b2u8 = require('buffer-to-uint8array')
|
|
|
|
module.exports = read
|
|
|
|
function read (data, o) {
|
|
var jpegData = jpeg.decode(data)
|
|
|
|
if(!jpegData) {
|
|
throw new Error("Error decoding jpeg")
|
|
}
|
|
|
|
return {
|
|
data: b2u8(jpegData.data),
|
|
height: jpegData.height,
|
|
width: jpegData.width
|
|
}
|
|
}
|
|
|
|
|