Files
radio-scraper/index.js
2021-03-01 13:34:02 -07:00

23 lines
544 B
JavaScript

const spawn = require('child_process').spawn;
function readFromRegion(frame: Buffer, x: int, y: int, width: int, height: int) {
const convert = spawn('convert', ['-', '-negate', '-crop', `${width}x${height}+${x}+${y}`, '-'])
const result = new Buffer(512 * 1024)
let resultSize = 0
convert.stdout.on('data', (data) => {
if (data.length + resultSize > result.length) {
// Buffer not big enough
} else {
resultSize += data.length
data.copy(result)
}
});
convert.on('exit', (code) => {
});
convert.stdin.write(frame)
}