@depup/sharp-cli 5.2.0-depup.0 → 5.3.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +2 -0
- package/.prettierrc +1 -0
- package/CHANGELOG.md +20 -8
- package/README.md +5 -5
- package/bin/cli.js +3 -3
- package/changes.json +5 -5
- package/cmd/channel-manipulation/bandbool.js +22 -16
- package/cmd/channel-manipulation/ensure-alpha.js +25 -17
- package/cmd/channel-manipulation/extract-channel.js +24 -16
- package/cmd/channel-manipulation/join-channel.js +17 -15
- package/cmd/channel-manipulation/remove-alpha.js +13 -10
- package/cmd/colour-manipulation/greyscale.js +17 -11
- package/cmd/colour-manipulation/pipeline-colourspace.js +26 -18
- package/cmd/colour-manipulation/tint.js +17 -14
- package/cmd/colour-manipulation/tocolourspace.js +23 -18
- package/cmd/compositing/composite.js +127 -99
- package/cmd/operations/affine.js +53 -45
- package/cmd/operations/blur.js +44 -36
- package/cmd/operations/boolean.js +23 -18
- package/cmd/operations/clahe.js +36 -31
- package/cmd/operations/convolve.js +51 -43
- package/cmd/operations/dilate.js +64 -0
- package/cmd/operations/erode.js +64 -0
- package/cmd/operations/flatten.js +24 -19
- package/cmd/operations/flip.js +12 -10
- package/cmd/operations/flop.js +12 -10
- package/cmd/operations/gamma.js +27 -20
- package/cmd/operations/linear.js +31 -24
- package/cmd/operations/median.js +19 -17
- package/cmd/operations/modulate.js +36 -26
- package/cmd/operations/negate.js +18 -15
- package/cmd/operations/normalise.js +27 -20
- package/cmd/operations/recomb.js +35 -27
- package/cmd/operations/rotate.js +32 -24
- package/cmd/operations/sharpen.js +45 -40
- package/cmd/operations/threshold.js +30 -24
- package/cmd/operations/unflatten.js +15 -11
- package/cmd/output.js +59 -51
- package/cmd/resizing/extend.js +56 -44
- package/cmd/resizing/extract.js +33 -28
- package/cmd/resizing/resize.js +80 -51
- package/cmd/resizing/trim.js +50 -31
- package/lib/cli.js +480 -366
- package/lib/constants.js +23 -15
- package/lib/convert.js +47 -52
- package/lib/index.js +23 -19
- package/lib/queue.js +8 -7
- package/package.json +12 -13
package/cmd/operations/clahe.js
CHANGED
|
@@ -24,59 +24,64 @@
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#clahe
|
|
25
25
|
|
|
26
26
|
// Strict mode.
|
|
27
|
-
|
|
27
|
+
"use strict";
|
|
28
28
|
|
|
29
29
|
// Local modules.
|
|
30
|
-
const queue = require(
|
|
30
|
+
const queue = require("../../lib/queue");
|
|
31
31
|
|
|
32
32
|
// Configure.
|
|
33
33
|
const positionals = {
|
|
34
34
|
height: {
|
|
35
|
-
desc:
|
|
36
|
-
type:
|
|
35
|
+
desc: "Height of the region",
|
|
36
|
+
type: "number",
|
|
37
37
|
},
|
|
38
38
|
width: {
|
|
39
|
-
desc:
|
|
40
|
-
type:
|
|
41
|
-
}
|
|
42
|
-
}
|
|
39
|
+
desc: "Width of the region",
|
|
40
|
+
type: "number",
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
43
|
|
|
44
44
|
const options = {
|
|
45
45
|
maxSlope: {
|
|
46
46
|
defaultDescription: 3,
|
|
47
|
-
desc:
|
|
48
|
-
type:
|
|
49
|
-
}
|
|
50
|
-
}
|
|
47
|
+
desc: "Maximum value for the slope of the cumulative histogram",
|
|
48
|
+
type: "number",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
51
|
|
|
52
52
|
// Command builder.
|
|
53
53
|
const builder = (yargs) => {
|
|
54
|
-
const optionNames = Object.keys(options)
|
|
54
|
+
const optionNames = Object.keys(options);
|
|
55
55
|
return yargs
|
|
56
56
|
.strict()
|
|
57
|
-
.example(
|
|
58
|
-
.epilog(
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
.example("$0 clahe 3 3")
|
|
58
|
+
.epilog(
|
|
59
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#clahe",
|
|
60
|
+
)
|
|
61
|
+
.positional("height", positionals.height)
|
|
62
|
+
.positional("width", positionals.width)
|
|
61
63
|
.options(options)
|
|
62
|
-
.group(optionNames,
|
|
63
|
-
}
|
|
64
|
+
.group(optionNames, "Command Options");
|
|
65
|
+
};
|
|
64
66
|
|
|
65
67
|
// Command handler.
|
|
66
68
|
const handler = (args) => {
|
|
67
|
-
return queue.push([
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
69
|
+
return queue.push([
|
|
70
|
+
"clahe",
|
|
71
|
+
(sharp) => {
|
|
72
|
+
return sharp.clahe({
|
|
73
|
+
width: args.width,
|
|
74
|
+
height: args.height,
|
|
75
|
+
maxSlope: args.maxSlope,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
]);
|
|
79
|
+
};
|
|
75
80
|
|
|
76
81
|
// Exports.
|
|
77
82
|
module.exports = {
|
|
78
|
-
command:
|
|
79
|
-
describe:
|
|
83
|
+
command: "clahe <width> <height>",
|
|
84
|
+
describe: "Perform contrast limiting adaptive histogram equalization CLAHE",
|
|
80
85
|
builder,
|
|
81
|
-
handler
|
|
82
|
-
}
|
|
86
|
+
handler,
|
|
87
|
+
};
|
|
@@ -24,80 +24,88 @@
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#convolve
|
|
25
25
|
|
|
26
26
|
// Strict mode.
|
|
27
|
-
|
|
27
|
+
"use strict";
|
|
28
28
|
|
|
29
29
|
// Package modules.
|
|
30
|
-
const pick = require(
|
|
30
|
+
const pick = require("lodash.pick");
|
|
31
31
|
|
|
32
32
|
// Local modules.
|
|
33
|
-
const queue = require(
|
|
33
|
+
const queue = require("../../lib/queue");
|
|
34
34
|
|
|
35
35
|
// Configure.
|
|
36
36
|
const positionals = {
|
|
37
37
|
height: {
|
|
38
|
-
desc:
|
|
39
|
-
type:
|
|
38
|
+
desc: "Height of the kernel in pixels",
|
|
39
|
+
type: "number",
|
|
40
40
|
},
|
|
41
41
|
kernel: {
|
|
42
|
-
desc:
|
|
42
|
+
desc: "Array of length width × height containing the kernel values",
|
|
43
43
|
defaultDescription: '"-1 0 1 -2 0 2 -1 0 1"',
|
|
44
|
-
type:
|
|
44
|
+
type: "number",
|
|
45
45
|
},
|
|
46
46
|
width: {
|
|
47
|
-
desc:
|
|
48
|
-
type:
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const positionalNames = Object.keys(positionals)
|
|
47
|
+
desc: "Width of the kernel in pixels",
|
|
48
|
+
type: "number",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
const positionalNames = Object.keys(positionals);
|
|
52
52
|
|
|
53
53
|
const options = {
|
|
54
54
|
scale: {
|
|
55
|
-
desc:
|
|
56
|
-
defaultDescription:
|
|
57
|
-
type:
|
|
55
|
+
desc: "The scale of the kernel in pixels",
|
|
56
|
+
defaultDescription: "sum",
|
|
57
|
+
type: "number",
|
|
58
58
|
},
|
|
59
59
|
offset: {
|
|
60
|
-
desc:
|
|
61
|
-
defaultDescription:
|
|
62
|
-
type:
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const optionNames = Object.keys(options)
|
|
60
|
+
desc: "The offset of the kernel in pixels",
|
|
61
|
+
defaultDescription: "0",
|
|
62
|
+
type: "number",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
const optionNames = Object.keys(options);
|
|
66
66
|
|
|
67
67
|
// Command builder.
|
|
68
68
|
const builder = (yargs) => {
|
|
69
69
|
return yargs
|
|
70
70
|
.strict()
|
|
71
|
-
.example(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
.example(
|
|
72
|
+
'$0 convolve 3 3 "-1 0 1 -2 0 2 -1 0 1"',
|
|
73
|
+
"The output will be the convolution of the input image with the horizontal Sobel operator",
|
|
74
|
+
)
|
|
75
|
+
.epilog(
|
|
76
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#convolve",
|
|
77
|
+
)
|
|
78
|
+
.check((argv) => {
|
|
79
|
+
const length = argv.width * argv.height;
|
|
75
80
|
if (!(Array.isArray(argv.kernel) && argv.kernel.length === length)) {
|
|
76
|
-
throw new Error(`Expected kernel positional to have ${length} values`)
|
|
81
|
+
throw new Error(`Expected kernel positional to have ${length} values`);
|
|
77
82
|
}
|
|
78
|
-
return true
|
|
83
|
+
return true;
|
|
79
84
|
})
|
|
80
85
|
.options(options)
|
|
81
|
-
.positional(
|
|
82
|
-
.positional(
|
|
83
|
-
.positional(
|
|
84
|
-
.group(optionNames,
|
|
85
|
-
}
|
|
86
|
+
.positional("kernel", positionals.kernel)
|
|
87
|
+
.positional("height", positionals.height)
|
|
88
|
+
.positional("width", positionals.width)
|
|
89
|
+
.group(optionNames, "Command Options");
|
|
90
|
+
};
|
|
86
91
|
|
|
87
92
|
// Command handler.
|
|
88
93
|
const handler = (args) => {
|
|
89
|
-
return queue.push([
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
94
|
+
return queue.push([
|
|
95
|
+
"convolve",
|
|
96
|
+
(sharp) => {
|
|
97
|
+
return sharp.convolve({
|
|
98
|
+
...pick(args, positionalNames),
|
|
99
|
+
...pick(args, optionNames),
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
]);
|
|
103
|
+
};
|
|
96
104
|
|
|
97
105
|
// Exports.
|
|
98
106
|
module.exports = {
|
|
99
|
-
command:
|
|
100
|
-
describe:
|
|
107
|
+
command: "convolve <width> <height> <kernel..>",
|
|
108
|
+
describe: "Convolve the image with the specified kernel",
|
|
101
109
|
builder,
|
|
102
|
-
handler
|
|
103
|
-
}
|
|
110
|
+
handler,
|
|
111
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2019 Mark van Seventer
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
* the Software without restriction, including without limitation the rights to
|
|
9
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
10
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
19
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
20
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// @see https://sharp.pixelplumbing.com/api-operation#dilate
|
|
25
|
+
|
|
26
|
+
// Strict mode.
|
|
27
|
+
"use strict";
|
|
28
|
+
|
|
29
|
+
// Local modules.
|
|
30
|
+
const queue = require("../../lib/queue");
|
|
31
|
+
|
|
32
|
+
// Configure.
|
|
33
|
+
const positionals = {
|
|
34
|
+
width: {
|
|
35
|
+
desc: "Dilation width in pixels",
|
|
36
|
+
defaultDescription: 1,
|
|
37
|
+
type: "number",
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Command builder.
|
|
42
|
+
const builder = (yargs) => {
|
|
43
|
+
return yargs
|
|
44
|
+
.strict()
|
|
45
|
+
.example("$0 dilate")
|
|
46
|
+
.example("$0 dilate 3")
|
|
47
|
+
.epilog(
|
|
48
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#dilate",
|
|
49
|
+
)
|
|
50
|
+
.positional("width", positionals.width);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Command handler.
|
|
54
|
+
const handler = (args) => {
|
|
55
|
+
return queue.push(["dilate", (sharp) => sharp.dilate(args.width)]);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Exports.
|
|
59
|
+
module.exports = {
|
|
60
|
+
command: "dilate [width]",
|
|
61
|
+
describe: "Expand foreground objects using the dilate morphological operator",
|
|
62
|
+
builder,
|
|
63
|
+
handler,
|
|
64
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2019 Mark van Seventer
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
* the Software without restriction, including without limitation the rights to
|
|
9
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
10
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
19
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
20
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// @see https://sharp.pixelplumbing.com/api-operation#erode
|
|
25
|
+
|
|
26
|
+
// Strict mode.
|
|
27
|
+
"use strict";
|
|
28
|
+
|
|
29
|
+
// Local modules.
|
|
30
|
+
const queue = require("../../lib/queue");
|
|
31
|
+
|
|
32
|
+
// Configure.
|
|
33
|
+
const positionals = {
|
|
34
|
+
width: {
|
|
35
|
+
desc: "Erosion width in pixels",
|
|
36
|
+
defaultDescription: 1,
|
|
37
|
+
type: "number",
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Command builder.
|
|
42
|
+
const builder = (yargs) => {
|
|
43
|
+
return yargs
|
|
44
|
+
.strict()
|
|
45
|
+
.example("$0 erode")
|
|
46
|
+
.example("$0 erode 3")
|
|
47
|
+
.epilog(
|
|
48
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#erode",
|
|
49
|
+
)
|
|
50
|
+
.positional("width", positionals.width);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Command handler.
|
|
54
|
+
const handler = (args) => {
|
|
55
|
+
return queue.push(["erode", (sharp) => sharp.erode(args.width)]);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Exports.
|
|
59
|
+
module.exports = {
|
|
60
|
+
command: "erode [width]",
|
|
61
|
+
describe: "Shrink foreground objects using the erode morphological operator",
|
|
62
|
+
builder,
|
|
63
|
+
handler,
|
|
64
|
+
};
|
|
@@ -21,43 +21,48 @@
|
|
|
21
21
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
// @see https://sharp.
|
|
24
|
+
// @see https://sharp.pixelplumbing.com/api-operation#flatten
|
|
25
25
|
|
|
26
26
|
// Strict mode.
|
|
27
|
-
|
|
27
|
+
"use strict";
|
|
28
28
|
|
|
29
29
|
// Local modules.
|
|
30
|
-
const queue = require(
|
|
30
|
+
const queue = require("../../lib/queue");
|
|
31
31
|
|
|
32
32
|
// Configure.
|
|
33
33
|
const positionals = {
|
|
34
34
|
background: {
|
|
35
|
-
defaultDescription:
|
|
36
|
-
desc:
|
|
37
|
-
type:
|
|
38
|
-
}
|
|
39
|
-
}
|
|
35
|
+
defaultDescription: "rgb(0, 0, 0)",
|
|
36
|
+
desc: "Background colour, parsed by the color module",
|
|
37
|
+
type: "string",
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
40
|
|
|
41
41
|
// Command builder.
|
|
42
42
|
const builder = (yargs) => {
|
|
43
43
|
return yargs
|
|
44
44
|
.strict()
|
|
45
45
|
.example('$0 flatten "#F0A703"')
|
|
46
|
-
.epilog(
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
.epilog(
|
|
47
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#flatten",
|
|
48
|
+
)
|
|
49
|
+
.positional("background", positionals.background);
|
|
50
|
+
};
|
|
49
51
|
|
|
50
52
|
// Command handler.
|
|
51
53
|
const handler = (args) => {
|
|
52
|
-
return queue.push([
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
54
|
+
return queue.push([
|
|
55
|
+
"flatten",
|
|
56
|
+
(sharp) => {
|
|
57
|
+
return sharp.flatten({ background: args.background });
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
};
|
|
56
61
|
|
|
57
62
|
// Exports.
|
|
58
63
|
module.exports = {
|
|
59
|
-
command:
|
|
60
|
-
describe:
|
|
64
|
+
command: "flatten [background]",
|
|
65
|
+
describe: "Merge alpha transparency channel, if any, with a background",
|
|
61
66
|
builder,
|
|
62
|
-
handler
|
|
63
|
-
}
|
|
67
|
+
handler,
|
|
68
|
+
};
|
package/cmd/operations/flip.js
CHANGED
|
@@ -24,26 +24,28 @@
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#flip
|
|
25
25
|
|
|
26
26
|
// Strict mode.
|
|
27
|
-
|
|
27
|
+
"use strict";
|
|
28
28
|
|
|
29
29
|
// Local modules.
|
|
30
|
-
const queue = require(
|
|
30
|
+
const queue = require("../../lib/queue");
|
|
31
31
|
|
|
32
32
|
// Command builder.
|
|
33
33
|
const builder = (yargs) => {
|
|
34
34
|
return yargs
|
|
35
35
|
.strict()
|
|
36
|
-
.epilog(
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
.epilog(
|
|
37
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#flip",
|
|
38
|
+
)
|
|
39
|
+
.example("$0 flip");
|
|
40
|
+
};
|
|
39
41
|
|
|
40
42
|
// Command handler.
|
|
41
|
-
const handler = (args) => queue.push([
|
|
43
|
+
const handler = (args) => queue.push(["flip", (sharp) => sharp.flip()]);
|
|
42
44
|
|
|
43
45
|
// Exports.
|
|
44
46
|
module.exports = {
|
|
45
|
-
command:
|
|
46
|
-
describe:
|
|
47
|
+
command: "flip",
|
|
48
|
+
describe: "Flip the image about the vertical Y axis",
|
|
47
49
|
builder,
|
|
48
|
-
handler
|
|
49
|
-
}
|
|
50
|
+
handler,
|
|
51
|
+
};
|
package/cmd/operations/flop.js
CHANGED
|
@@ -24,26 +24,28 @@
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#flop
|
|
25
25
|
|
|
26
26
|
// Strict mode.
|
|
27
|
-
|
|
27
|
+
"use strict";
|
|
28
28
|
|
|
29
29
|
// Local modules.
|
|
30
|
-
const queue = require(
|
|
30
|
+
const queue = require("../../lib/queue");
|
|
31
31
|
|
|
32
32
|
// Command builder.
|
|
33
33
|
const builder = (yargs) => {
|
|
34
34
|
return yargs
|
|
35
35
|
.strict()
|
|
36
|
-
.epilog(
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
.epilog(
|
|
37
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#flop",
|
|
38
|
+
)
|
|
39
|
+
.example("$0 flop");
|
|
40
|
+
};
|
|
39
41
|
|
|
40
42
|
// Command handler.
|
|
41
|
-
const handler = (args) => queue.push([
|
|
43
|
+
const handler = (args) => queue.push(["flop", (sharp) => sharp.flop()]);
|
|
42
44
|
|
|
43
45
|
// Exports.
|
|
44
46
|
module.exports = {
|
|
45
|
-
command:
|
|
46
|
-
describe:
|
|
47
|
+
command: "flop",
|
|
48
|
+
describe: "Flop the image about the horizontal X axis",
|
|
47
49
|
builder,
|
|
48
|
-
handler
|
|
49
|
-
}
|
|
50
|
+
handler,
|
|
51
|
+
};
|
package/cmd/operations/gamma.js
CHANGED
|
@@ -24,43 +24,50 @@
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#gamma
|
|
25
25
|
|
|
26
26
|
// Strict mode.
|
|
27
|
-
|
|
27
|
+
"use strict";
|
|
28
28
|
|
|
29
29
|
// Local modules.
|
|
30
|
-
const queue = require(
|
|
30
|
+
const queue = require("../../lib/queue");
|
|
31
31
|
|
|
32
32
|
// Configure.
|
|
33
33
|
const positionals = {
|
|
34
34
|
gamma: {
|
|
35
|
-
desc:
|
|
35
|
+
desc: "The gamma factor",
|
|
36
36
|
defaultDescription: 2.2,
|
|
37
|
-
type:
|
|
37
|
+
type: "number",
|
|
38
38
|
},
|
|
39
39
|
gammaOut: {
|
|
40
|
-
desc:
|
|
41
|
-
defaultDescription:
|
|
42
|
-
type:
|
|
43
|
-
}
|
|
44
|
-
}
|
|
40
|
+
desc: "The gamma factor used for scaling",
|
|
41
|
+
defaultDescription: "<gamma>",
|
|
42
|
+
type: "number",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
45
|
|
|
46
46
|
// Command builder.
|
|
47
47
|
const builder = (yargs) => {
|
|
48
48
|
return yargs
|
|
49
49
|
.strict()
|
|
50
|
-
.epilog(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
.epilog(
|
|
51
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#gamma",
|
|
52
|
+
)
|
|
53
|
+
.positional("gamma", positionals.gamma)
|
|
54
|
+
.positional("gammaOut", positionals.gammaOut);
|
|
55
|
+
};
|
|
54
56
|
|
|
55
57
|
// Command handler.
|
|
56
|
-
const handler = (args) =>
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
const handler = (args) =>
|
|
59
|
+
queue.push([
|
|
60
|
+
"gamma",
|
|
61
|
+
(sharp) => {
|
|
62
|
+
return sharp.gamma(args.gamma, args.gammaOut);
|
|
63
|
+
},
|
|
64
|
+
]);
|
|
59
65
|
|
|
60
66
|
// Exports.
|
|
61
67
|
module.exports = {
|
|
62
|
-
command:
|
|
63
|
-
describe:
|
|
68
|
+
command: "gamma [gamma] [gammaOut]",
|
|
69
|
+
describe:
|
|
70
|
+
"Apply a gamma correction by reducing the encoding (darken) pre-resize then increasing the encoding (brighten) post-resize",
|
|
64
71
|
builder,
|
|
65
|
-
handler
|
|
66
|
-
}
|
|
72
|
+
handler,
|
|
73
|
+
};
|
package/cmd/operations/linear.js
CHANGED
|
@@ -24,50 +24,57 @@
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#linear
|
|
25
25
|
|
|
26
26
|
// Strict mode.
|
|
27
|
-
|
|
27
|
+
"use strict";
|
|
28
28
|
|
|
29
29
|
// Local modules.
|
|
30
|
-
const queue = require(
|
|
30
|
+
const queue = require("../../lib/queue");
|
|
31
31
|
|
|
32
32
|
// Configure.
|
|
33
33
|
const positionals = {
|
|
34
34
|
multiplier: {
|
|
35
|
-
desc:
|
|
35
|
+
desc: "Multiplier",
|
|
36
36
|
default: 1.0,
|
|
37
|
-
type:
|
|
38
|
-
}
|
|
39
|
-
}
|
|
37
|
+
type: "number",
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
40
|
|
|
41
41
|
const options = {
|
|
42
42
|
offset: {
|
|
43
|
-
desc:
|
|
44
|
-
type:
|
|
45
|
-
}
|
|
46
|
-
}
|
|
43
|
+
desc: "Offset",
|
|
44
|
+
type: "array",
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
47
|
|
|
48
48
|
// Command builder.
|
|
49
49
|
const builder = (yargs) => {
|
|
50
|
-
const optionNames = Object.keys(options)
|
|
50
|
+
const optionNames = Object.keys(options);
|
|
51
51
|
return yargs
|
|
52
52
|
.strict()
|
|
53
|
-
.example(
|
|
54
|
-
.example(
|
|
55
|
-
.epilog(
|
|
56
|
-
|
|
53
|
+
.example("$0 linear 0.5 --offset 2")
|
|
54
|
+
.example("$0 linear 0.25 0.5 0.75 --offset 150 100 50")
|
|
55
|
+
.epilog(
|
|
56
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#linear",
|
|
57
|
+
)
|
|
58
|
+
.positional("multiplier", positionals.multiplier)
|
|
57
59
|
.options(options)
|
|
58
|
-
.group(optionNames,
|
|
59
|
-
}
|
|
60
|
+
.group(optionNames, "Command Options");
|
|
61
|
+
};
|
|
60
62
|
|
|
61
63
|
// Command handler.
|
|
62
64
|
const handler = (args) => {
|
|
63
|
-
const multiplier =
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
const multiplier =
|
|
66
|
+
args.multiplier.length === 1 ? args.multiplier[0] : args.multiplier;
|
|
67
|
+
return queue.push([
|
|
68
|
+
"linear",
|
|
69
|
+
(sharp) => sharp.linear(multiplier, args.offset),
|
|
70
|
+
]);
|
|
71
|
+
};
|
|
66
72
|
|
|
67
73
|
// Exports.
|
|
68
74
|
module.exports = {
|
|
69
|
-
command:
|
|
70
|
-
describe:
|
|
75
|
+
command: "linear [multiplier..]",
|
|
76
|
+
describe:
|
|
77
|
+
"Apply the linear formula a × input + b to the image to adjust image levels",
|
|
71
78
|
builder,
|
|
72
|
-
handler
|
|
73
|
-
}
|
|
79
|
+
handler,
|
|
80
|
+
};
|