@depup/sharp-cli 5.2.0-depup.0 → 6.0.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/.github/workflows/ci.yml +30 -0
- package/.prettierignore +2 -0
- package/.prettierrc +1 -0
- package/CHANGELOG.md +40 -8
- package/README.md +6 -9
- package/bin/cli.js +5 -5
- package/changes.json +5 -17
- package/cmd/channel-manipulation/bandbool.js +24 -19
- package/cmd/channel-manipulation/ensure-alpha.js +27 -22
- package/cmd/channel-manipulation/extract-channel.js +23 -19
- package/cmd/channel-manipulation/join-channel.js +19 -20
- package/cmd/channel-manipulation/remove-alpha.js +12 -15
- package/cmd/colour-manipulation/greyscale.js +16 -16
- package/cmd/colour-manipulation/pipeline-colourspace.js +26 -22
- package/cmd/colour-manipulation/tint.js +17 -19
- package/cmd/colour-manipulation/tocolourspace.js +22 -21
- package/cmd/compositing/composite.js +133 -102
- package/cmd/operations/affine.js +57 -51
- package/cmd/operations/blur.js +44 -41
- package/cmd/operations/boolean.js +22 -21
- package/cmd/operations/clahe.js +37 -37
- package/cmd/operations/convolve.js +52 -48
- package/cmd/operations/dilate.js +58 -0
- package/cmd/operations/erode.js +58 -0
- package/cmd/operations/flatten.js +23 -24
- package/cmd/operations/flip.js +12 -15
- package/cmd/operations/flop.js +12 -15
- package/cmd/operations/gamma.js +26 -25
- package/cmd/operations/linear.js +30 -29
- package/cmd/operations/median.js +18 -22
- package/cmd/operations/modulate.js +42 -31
- package/cmd/operations/negate.js +17 -20
- package/cmd/operations/normalise.js +28 -25
- package/cmd/operations/recomb.js +34 -32
- package/cmd/operations/rotate.js +31 -29
- package/cmd/operations/sharpen.js +49 -45
- package/cmd/operations/threshold.js +29 -29
- package/cmd/operations/unflatten.js +14 -16
- package/cmd/output.js +61 -56
- package/cmd/resizing/extend.js +55 -49
- package/cmd/resizing/extract.js +32 -33
- package/cmd/resizing/resize.js +79 -56
- package/cmd/resizing/trim.js +59 -36
- package/{lib/queue.js → eslint.config.mjs} +21 -17
- package/lib/cli.js +637 -383
- package/lib/constants.js +24 -18
- package/lib/convert.js +106 -73
- package/lib/index.js +56 -23
- package/lib/utils.js +50 -0
- package/package.json +27 -37
|
@@ -23,44 +23,45 @@
|
|
|
23
23
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#boolean
|
|
25
25
|
|
|
26
|
-
// Strict mode.
|
|
27
|
-
'use strict'
|
|
28
|
-
|
|
29
26
|
// Local modules.
|
|
30
|
-
|
|
31
|
-
const queue = require('../../lib/queue')
|
|
27
|
+
import constants from "../../lib/constants.js";
|
|
32
28
|
|
|
33
29
|
// Configure.
|
|
34
30
|
const positionals = {
|
|
35
31
|
operand: {
|
|
36
|
-
desc:
|
|
32
|
+
desc: "Path to an image file",
|
|
37
33
|
normalize: true,
|
|
38
|
-
type:
|
|
34
|
+
type: "string",
|
|
39
35
|
},
|
|
40
36
|
operator: {
|
|
41
37
|
choices: constants.BOOL,
|
|
42
|
-
desc:
|
|
43
|
-
}
|
|
44
|
-
}
|
|
38
|
+
desc: "Operator to perform that bitwise operation",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
45
41
|
|
|
46
42
|
// Command builder.
|
|
47
43
|
const builder = (yargs) => {
|
|
48
44
|
return yargs
|
|
49
45
|
.strict()
|
|
50
|
-
.epilog(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
.epilog(
|
|
47
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#boolean",
|
|
48
|
+
)
|
|
49
|
+
.positional("operand", positionals.operand)
|
|
50
|
+
.positional("operator", positionals.operator);
|
|
51
|
+
};
|
|
54
52
|
|
|
55
53
|
// Command handler.
|
|
56
54
|
const handler = (args) => {
|
|
57
|
-
return queue.push([
|
|
58
|
-
|
|
55
|
+
return args["#queue"].push([
|
|
56
|
+
"boolean",
|
|
57
|
+
(sharp) => sharp.boolean(args.operand, args.operator),
|
|
58
|
+
]);
|
|
59
|
+
};
|
|
59
60
|
|
|
60
61
|
// Exports.
|
|
61
|
-
|
|
62
|
-
command:
|
|
63
|
-
describe:
|
|
62
|
+
export default {
|
|
63
|
+
command: "boolean <operand> <operator>",
|
|
64
|
+
describe: "Perform a bitwise boolean operation with operand image",
|
|
64
65
|
builder,
|
|
65
|
-
handler
|
|
66
|
-
}
|
|
66
|
+
handler,
|
|
67
|
+
};
|
package/cmd/operations/clahe.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* The MIT License (MIT)
|
|
3
3
|
*
|
|
4
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) 2019 Mark van Seventer
|
|
5
5
|
*
|
|
6
6
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
7
|
* this software and associated documentation files (the "Software"), to deal in
|
|
@@ -23,60 +23,60 @@
|
|
|
23
23
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#clahe
|
|
25
25
|
|
|
26
|
-
// Strict mode.
|
|
27
|
-
'use strict'
|
|
28
|
-
|
|
29
|
-
// Local modules.
|
|
30
|
-
const queue = require('../../lib/queue')
|
|
31
|
-
|
|
32
26
|
// Configure.
|
|
33
27
|
const positionals = {
|
|
34
28
|
height: {
|
|
35
|
-
desc:
|
|
36
|
-
type:
|
|
29
|
+
desc: "Height of the region",
|
|
30
|
+
type: "number",
|
|
37
31
|
},
|
|
38
32
|
width: {
|
|
39
|
-
desc:
|
|
40
|
-
type:
|
|
41
|
-
}
|
|
42
|
-
}
|
|
33
|
+
desc: "Width of the region",
|
|
34
|
+
type: "number",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
43
37
|
|
|
44
38
|
const options = {
|
|
45
39
|
maxSlope: {
|
|
46
40
|
defaultDescription: 3,
|
|
47
|
-
desc:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
41
|
+
desc: "Maximum value for the slope of the cumulative histogram",
|
|
42
|
+
nargs: 1,
|
|
43
|
+
type: "number",
|
|
44
|
+
},
|
|
45
|
+
};
|
|
51
46
|
|
|
52
47
|
// Command builder.
|
|
53
48
|
const builder = (yargs) => {
|
|
54
|
-
const optionNames = Object.keys(options)
|
|
49
|
+
const optionNames = Object.keys(options);
|
|
55
50
|
return yargs
|
|
56
51
|
.strict()
|
|
57
|
-
.example(
|
|
58
|
-
.epilog(
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
.example("$0 clahe 3 3")
|
|
53
|
+
.epilog(
|
|
54
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#clahe",
|
|
55
|
+
)
|
|
56
|
+
.positional("height", positionals.height)
|
|
57
|
+
.positional("width", positionals.width)
|
|
61
58
|
.options(options)
|
|
62
|
-
.group(optionNames,
|
|
63
|
-
}
|
|
59
|
+
.group(optionNames, "Command Options");
|
|
60
|
+
};
|
|
64
61
|
|
|
65
62
|
// Command handler.
|
|
66
63
|
const handler = (args) => {
|
|
67
|
-
return queue.push([
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
64
|
+
return args["#queue"].push([
|
|
65
|
+
"clahe",
|
|
66
|
+
(sharp) => {
|
|
67
|
+
return sharp.clahe({
|
|
68
|
+
width: args.width,
|
|
69
|
+
height: args.height,
|
|
70
|
+
maxSlope: args.maxSlope,
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
74
|
+
};
|
|
75
75
|
|
|
76
76
|
// Exports.
|
|
77
|
-
|
|
78
|
-
command:
|
|
79
|
-
describe:
|
|
77
|
+
export default {
|
|
78
|
+
command: "clahe <width> <height>",
|
|
79
|
+
describe: "Perform contrast limiting adaptive histogram equalization CLAHE",
|
|
80
80
|
builder,
|
|
81
|
-
handler
|
|
82
|
-
}
|
|
81
|
+
handler,
|
|
82
|
+
};
|
|
@@ -23,81 +23,85 @@
|
|
|
23
23
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#convolve
|
|
25
25
|
|
|
26
|
-
// Strict mode.
|
|
27
|
-
'use strict'
|
|
28
|
-
|
|
29
|
-
// Package modules.
|
|
30
|
-
const pick = require('lodash.pick')
|
|
31
|
-
|
|
32
26
|
// Local modules.
|
|
33
|
-
|
|
27
|
+
import { pick } from "../../lib/utils.js";
|
|
34
28
|
|
|
35
29
|
// Configure.
|
|
36
30
|
const positionals = {
|
|
37
31
|
height: {
|
|
38
|
-
desc:
|
|
39
|
-
type:
|
|
32
|
+
desc: "Height of the kernel in pixels",
|
|
33
|
+
type: "number",
|
|
40
34
|
},
|
|
41
35
|
kernel: {
|
|
42
|
-
desc:
|
|
36
|
+
desc: "Array of length width × height containing the kernel values",
|
|
43
37
|
defaultDescription: '"-1 0 1 -2 0 2 -1 0 1"',
|
|
44
|
-
type:
|
|
38
|
+
type: "number",
|
|
45
39
|
},
|
|
46
40
|
width: {
|
|
47
|
-
desc:
|
|
48
|
-
type:
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const positionalNames = Object.keys(positionals)
|
|
41
|
+
desc: "Width of the kernel in pixels",
|
|
42
|
+
type: "number",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const positionalNames = Object.keys(positionals);
|
|
52
46
|
|
|
53
47
|
const options = {
|
|
54
48
|
scale: {
|
|
55
|
-
desc:
|
|
56
|
-
defaultDescription:
|
|
57
|
-
|
|
49
|
+
desc: "The scale of the kernel in pixels",
|
|
50
|
+
defaultDescription: "sum",
|
|
51
|
+
nargs: 1,
|
|
52
|
+
type: "number",
|
|
58
53
|
},
|
|
59
54
|
offset: {
|
|
60
|
-
desc:
|
|
61
|
-
defaultDescription:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
55
|
+
desc: "The offset of the kernel in pixels",
|
|
56
|
+
defaultDescription: "0",
|
|
57
|
+
nargs: 1,
|
|
58
|
+
type: "number",
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
const optionNames = Object.keys(options);
|
|
66
62
|
|
|
67
63
|
// Command builder.
|
|
68
64
|
const builder = (yargs) => {
|
|
69
65
|
return yargs
|
|
70
66
|
.strict()
|
|
71
|
-
.example(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
.example(
|
|
68
|
+
'$0 convolve 3 3 "-1 0 1 -2 0 2 -1 0 1"',
|
|
69
|
+
"The output will be the convolution of the input image with the horizontal Sobel operator",
|
|
70
|
+
)
|
|
71
|
+
.epilog(
|
|
72
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#convolve",
|
|
73
|
+
)
|
|
74
|
+
.check((argv) => {
|
|
75
|
+
const length = argv.width * argv.height;
|
|
75
76
|
if (!(Array.isArray(argv.kernel) && argv.kernel.length === length)) {
|
|
76
|
-
throw new Error(`Expected kernel positional to have ${length} values`)
|
|
77
|
+
throw new Error(`Expected kernel positional to have ${length} values`);
|
|
77
78
|
}
|
|
78
|
-
return true
|
|
79
|
+
return true;
|
|
79
80
|
})
|
|
80
81
|
.options(options)
|
|
81
|
-
.positional(
|
|
82
|
-
.positional(
|
|
83
|
-
.positional(
|
|
84
|
-
.group(optionNames,
|
|
85
|
-
}
|
|
82
|
+
.positional("kernel", positionals.kernel)
|
|
83
|
+
.positional("height", positionals.height)
|
|
84
|
+
.positional("width", positionals.width)
|
|
85
|
+
.group(optionNames, "Command Options");
|
|
86
|
+
};
|
|
86
87
|
|
|
87
88
|
// Command handler.
|
|
88
89
|
const handler = (args) => {
|
|
89
|
-
return queue.push([
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
90
|
+
return args["#queue"].push([
|
|
91
|
+
"convolve",
|
|
92
|
+
(sharp) => {
|
|
93
|
+
return sharp.convolve({
|
|
94
|
+
...pick(args, positionalNames),
|
|
95
|
+
...pick(args, optionNames),
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
};
|
|
96
100
|
|
|
97
101
|
// Exports.
|
|
98
|
-
|
|
99
|
-
command:
|
|
100
|
-
describe:
|
|
102
|
+
export default {
|
|
103
|
+
command: "convolve <width> <height> <kernel..>",
|
|
104
|
+
describe: "Convolve the image with the specified kernel",
|
|
101
105
|
builder,
|
|
102
|
-
handler
|
|
103
|
-
}
|
|
106
|
+
handler,
|
|
107
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
// Configure.
|
|
27
|
+
const positionals = {
|
|
28
|
+
width: {
|
|
29
|
+
desc: "Dilation width in pixels",
|
|
30
|
+
defaultDescription: 1,
|
|
31
|
+
type: "number",
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Command builder.
|
|
36
|
+
const builder = (yargs) => {
|
|
37
|
+
return yargs
|
|
38
|
+
.strict()
|
|
39
|
+
.example("$0 dilate")
|
|
40
|
+
.example("$0 dilate 3")
|
|
41
|
+
.epilog(
|
|
42
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#dilate",
|
|
43
|
+
)
|
|
44
|
+
.positional("width", positionals.width);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Command handler.
|
|
48
|
+
const handler = (args) => {
|
|
49
|
+
return args["#queue"].push(["dilate", (sharp) => sharp.dilate(args.width)]);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Exports.
|
|
53
|
+
export default {
|
|
54
|
+
command: "dilate [width]",
|
|
55
|
+
describe: "Expand foreground objects using the dilate morphological operator",
|
|
56
|
+
builder,
|
|
57
|
+
handler,
|
|
58
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
// Configure.
|
|
27
|
+
const positionals = {
|
|
28
|
+
width: {
|
|
29
|
+
desc: "Erosion width in pixels",
|
|
30
|
+
defaultDescription: 1,
|
|
31
|
+
type: "number",
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Command builder.
|
|
36
|
+
const builder = (yargs) => {
|
|
37
|
+
return yargs
|
|
38
|
+
.strict()
|
|
39
|
+
.example("$0 erode")
|
|
40
|
+
.example("$0 erode 3")
|
|
41
|
+
.epilog(
|
|
42
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#erode",
|
|
43
|
+
)
|
|
44
|
+
.positional("width", positionals.width);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Command handler.
|
|
48
|
+
const handler = (args) => {
|
|
49
|
+
return args["#queue"].push(["erode", (sharp) => sharp.erode(args.width)]);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Exports.
|
|
53
|
+
export default {
|
|
54
|
+
command: "erode [width]",
|
|
55
|
+
describe: "Shrink foreground objects using the erode morphological operator",
|
|
56
|
+
builder,
|
|
57
|
+
handler,
|
|
58
|
+
};
|
|
@@ -21,43 +21,42 @@
|
|
|
21
21
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
// @see https://sharp.
|
|
25
|
-
|
|
26
|
-
// Strict mode.
|
|
27
|
-
'use strict'
|
|
28
|
-
|
|
29
|
-
// Local modules.
|
|
30
|
-
const queue = require('../../lib/queue')
|
|
24
|
+
// @see https://sharp.pixelplumbing.com/api-operation#flatten
|
|
31
25
|
|
|
32
26
|
// Configure.
|
|
33
27
|
const positionals = {
|
|
34
28
|
background: {
|
|
35
|
-
defaultDescription:
|
|
36
|
-
desc:
|
|
37
|
-
type:
|
|
38
|
-
}
|
|
39
|
-
}
|
|
29
|
+
defaultDescription: "rgb(0, 0, 0)",
|
|
30
|
+
desc: "Background colour, parsed by the color module",
|
|
31
|
+
type: "string",
|
|
32
|
+
},
|
|
33
|
+
};
|
|
40
34
|
|
|
41
35
|
// Command builder.
|
|
42
36
|
const builder = (yargs) => {
|
|
43
37
|
return yargs
|
|
44
38
|
.strict()
|
|
45
39
|
.example('$0 flatten "#F0A703"')
|
|
46
|
-
.epilog(
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
.epilog(
|
|
41
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#flatten",
|
|
42
|
+
)
|
|
43
|
+
.positional("background", positionals.background);
|
|
44
|
+
};
|
|
49
45
|
|
|
50
46
|
// Command handler.
|
|
51
47
|
const handler = (args) => {
|
|
52
|
-
return queue.push([
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
48
|
+
return args["#queue"].push([
|
|
49
|
+
"flatten",
|
|
50
|
+
(sharp) => {
|
|
51
|
+
return sharp.flatten({ background: args.background });
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
};
|
|
56
55
|
|
|
57
56
|
// Exports.
|
|
58
|
-
|
|
59
|
-
command:
|
|
60
|
-
describe:
|
|
57
|
+
export default {
|
|
58
|
+
command: "flatten [background]",
|
|
59
|
+
describe: "Merge alpha transparency channel, if any, with a background",
|
|
61
60
|
builder,
|
|
62
|
-
handler
|
|
63
|
-
}
|
|
61
|
+
handler,
|
|
62
|
+
};
|
package/cmd/operations/flip.js
CHANGED
|
@@ -23,27 +23,24 @@
|
|
|
23
23
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#flip
|
|
25
25
|
|
|
26
|
-
// Strict mode.
|
|
27
|
-
'use strict'
|
|
28
|
-
|
|
29
|
-
// Local modules.
|
|
30
|
-
const queue = require('../../lib/queue')
|
|
31
|
-
|
|
32
26
|
// Command builder.
|
|
33
27
|
const builder = (yargs) => {
|
|
34
28
|
return yargs
|
|
35
29
|
.strict()
|
|
36
|
-
.epilog(
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
.epilog(
|
|
31
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#flip",
|
|
32
|
+
)
|
|
33
|
+
.example("$0 flip");
|
|
34
|
+
};
|
|
39
35
|
|
|
40
36
|
// Command handler.
|
|
41
|
-
const handler = (args) =>
|
|
37
|
+
const handler = (args) =>
|
|
38
|
+
args["#queue"].push(["flip", (sharp) => sharp.flip()]);
|
|
42
39
|
|
|
43
40
|
// Exports.
|
|
44
|
-
|
|
45
|
-
command:
|
|
46
|
-
describe:
|
|
41
|
+
export default {
|
|
42
|
+
command: "flip",
|
|
43
|
+
describe: "Flip the image about the vertical Y axis",
|
|
47
44
|
builder,
|
|
48
|
-
handler
|
|
49
|
-
}
|
|
45
|
+
handler,
|
|
46
|
+
};
|
package/cmd/operations/flop.js
CHANGED
|
@@ -23,27 +23,24 @@
|
|
|
23
23
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#flop
|
|
25
25
|
|
|
26
|
-
// Strict mode.
|
|
27
|
-
'use strict'
|
|
28
|
-
|
|
29
|
-
// Local modules.
|
|
30
|
-
const queue = require('../../lib/queue')
|
|
31
|
-
|
|
32
26
|
// Command builder.
|
|
33
27
|
const builder = (yargs) => {
|
|
34
28
|
return yargs
|
|
35
29
|
.strict()
|
|
36
|
-
.epilog(
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
.epilog(
|
|
31
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#flop",
|
|
32
|
+
)
|
|
33
|
+
.example("$0 flop");
|
|
34
|
+
};
|
|
39
35
|
|
|
40
36
|
// Command handler.
|
|
41
|
-
const handler = (args) =>
|
|
37
|
+
const handler = (args) =>
|
|
38
|
+
args["#queue"].push(["flop", (sharp) => sharp.flop()]);
|
|
42
39
|
|
|
43
40
|
// Exports.
|
|
44
|
-
|
|
45
|
-
command:
|
|
46
|
-
describe:
|
|
41
|
+
export default {
|
|
42
|
+
command: "flop",
|
|
43
|
+
describe: "Flop the image about the horizontal X axis",
|
|
47
44
|
builder,
|
|
48
|
-
handler
|
|
49
|
-
}
|
|
45
|
+
handler,
|
|
46
|
+
};
|
package/cmd/operations/gamma.js
CHANGED
|
@@ -23,44 +23,45 @@
|
|
|
23
23
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#gamma
|
|
25
25
|
|
|
26
|
-
// Strict mode.
|
|
27
|
-
'use strict'
|
|
28
|
-
|
|
29
|
-
// Local modules.
|
|
30
|
-
const queue = require('../../lib/queue')
|
|
31
|
-
|
|
32
26
|
// Configure.
|
|
33
27
|
const positionals = {
|
|
34
28
|
gamma: {
|
|
35
|
-
desc:
|
|
29
|
+
desc: "The gamma factor",
|
|
36
30
|
defaultDescription: 2.2,
|
|
37
|
-
type:
|
|
31
|
+
type: "number",
|
|
38
32
|
},
|
|
39
33
|
gammaOut: {
|
|
40
|
-
desc:
|
|
41
|
-
defaultDescription:
|
|
42
|
-
type:
|
|
43
|
-
}
|
|
44
|
-
}
|
|
34
|
+
desc: "The gamma factor used for scaling",
|
|
35
|
+
defaultDescription: "<gamma>",
|
|
36
|
+
type: "number",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
45
39
|
|
|
46
40
|
// Command builder.
|
|
47
41
|
const builder = (yargs) => {
|
|
48
42
|
return yargs
|
|
49
43
|
.strict()
|
|
50
|
-
.epilog(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
.epilog(
|
|
45
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#gamma",
|
|
46
|
+
)
|
|
47
|
+
.positional("gamma", positionals.gamma)
|
|
48
|
+
.positional("gammaOut", positionals.gammaOut);
|
|
49
|
+
};
|
|
54
50
|
|
|
55
51
|
// Command handler.
|
|
56
|
-
const handler = (args) =>
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
const handler = (args) =>
|
|
53
|
+
args["#queue"].push([
|
|
54
|
+
"gamma",
|
|
55
|
+
(sharp) => {
|
|
56
|
+
return sharp.gamma(args.gamma, args.gammaOut);
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
59
|
|
|
60
60
|
// Exports.
|
|
61
|
-
|
|
62
|
-
command:
|
|
63
|
-
describe:
|
|
61
|
+
export default {
|
|
62
|
+
command: "gamma [gamma] [gammaOut]",
|
|
63
|
+
describe:
|
|
64
|
+
"Apply a gamma correction by reducing the encoding (darken) pre-resize then increasing the encoding (brighten) post-resize",
|
|
64
65
|
builder,
|
|
65
|
-
handler
|
|
66
|
-
}
|
|
66
|
+
handler,
|
|
67
|
+
};
|