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.
20 lines
356 B
20 lines
356 B
4 years ago
|
// decode png buffer
|
||
|
'use strict'
|
||
|
|
||
|
|
||
|
var PNG = require('pngjs').PNG
|
||
|
var toab = require('to-array-buffer')
|
||
|
|
||
|
module.exports = function read (data, o) {
|
||
|
var imgData = PNG.sync.read(Buffer.from(data))
|
||
|
|
||
|
var pixels = new Uint8Array(toab(imgData.data))
|
||
|
|
||
|
return {
|
||
|
data: pixels,
|
||
|
width: imgData.width | 0,
|
||
|
height: imgData.height | 0
|
||
|
}
|
||
|
}
|
||
|
|