Initial commit
This commit is contained in:
22
index.js
Normal file
22
index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user