-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin.js
executable file
·55 lines (46 loc) · 1.06 KB
/
bin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
':' //; exec "`command -v nodejs || command -v node`" "$0" "$@"
var pkg = JSON.parse( require('fs').readFileSync( require('path').resolve( __dirname, './package.json'),'utf8') );
var ArgumentParser = require('argparse').ArgumentParser;
var parser = new ArgumentParser({
version: pkg.version,
addHelp: true,
description: pkg.description
});
parser.addArgument(
[ '-o'],
{
help: 'Output file',
dest: 'output',
}
);
parser.addArgument(
[ 'input'],
{
help: 'Input PNG file',
narg: 1
}
);
parser.addArgument(
[ '-gray'],
{
help: 'Treat input as grayscale and act on RGB channels rather than alpha channel.',
action: 'storeTrue',
}
);
parser.addArgument(
[ '-t'],
{
help: 'Threshold for depths to be considered holes.',
type: 'int',
dest: 'threshold',
defaultValue: 10
}
);
var args = parser.parseArgs();
var infile = args.input;
var outfile = args.output || infile;
var channel = args.gray ? 0 : 3;
var threshold = args.threshold;
var processFile = require('./index.js').processFile;
processFile( infile, outfile, channel, threshold );