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.
23 lines
374 B
23 lines
374 B
4 years ago
|
// 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
|
||
|
}
|
||
|
}
|
||
|
|