@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
|
@@ -24,50 +24,56 @@
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-operation#threshold
|
|
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
|
value: {
|
|
35
|
-
desc:
|
|
35
|
+
desc: "A value in the range 0-255 representing the level at which the threshold will be applied",
|
|
36
36
|
defaultDescription: 128,
|
|
37
|
-
type:
|
|
38
|
-
}
|
|
39
|
-
}
|
|
37
|
+
type: "number",
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
40
|
|
|
41
41
|
const options = {
|
|
42
42
|
greyscale: {
|
|
43
|
-
alias:
|
|
44
|
-
desc:
|
|
45
|
-
type:
|
|
46
|
-
}
|
|
47
|
-
}
|
|
43
|
+
alias: "grayscale",
|
|
44
|
+
desc: "Convert to single channel greyscale",
|
|
45
|
+
type: "boolean",
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
48
|
|
|
49
49
|
// Command builder.
|
|
50
50
|
const builder = (yargs) => {
|
|
51
|
-
const optionNames = Object.keys(options)
|
|
51
|
+
const optionNames = Object.keys(options);
|
|
52
52
|
return yargs
|
|
53
53
|
.strict()
|
|
54
|
-
.epilog(
|
|
55
|
-
|
|
54
|
+
.epilog(
|
|
55
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#threshold",
|
|
56
|
+
)
|
|
57
|
+
.positional("value", positionals.value)
|
|
56
58
|
.options(options)
|
|
57
|
-
.group(optionNames,
|
|
58
|
-
}
|
|
59
|
+
.group(optionNames, "Command Options");
|
|
60
|
+
};
|
|
59
61
|
|
|
60
62
|
// Command handler.
|
|
61
63
|
const handler = (args) => {
|
|
62
|
-
return queue.push([
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
64
|
+
return queue.push([
|
|
65
|
+
"threshold",
|
|
66
|
+
(sharp) => {
|
|
67
|
+
return sharp.threshold(args.value, { greyscale: args.greyscale });
|
|
68
|
+
},
|
|
69
|
+
]);
|
|
70
|
+
};
|
|
66
71
|
|
|
67
72
|
// Exports.
|
|
68
73
|
module.exports = {
|
|
69
|
-
command:
|
|
70
|
-
describe:
|
|
74
|
+
command: "threshold [value]",
|
|
75
|
+
describe:
|
|
76
|
+
"Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0",
|
|
71
77
|
builder,
|
|
72
|
-
handler
|
|
73
|
-
}
|
|
78
|
+
handler,
|
|
79
|
+
};
|
|
@@ -21,29 +21,33 @@
|
|
|
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#unflatten
|
|
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
|
-
.example(
|
|
37
|
-
.epilog(
|
|
38
|
-
|
|
36
|
+
.example("$0 unflatten")
|
|
37
|
+
.epilog(
|
|
38
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#unflatten",
|
|
39
|
+
);
|
|
40
|
+
};
|
|
39
41
|
|
|
40
42
|
// Command handler.
|
|
41
|
-
const handler = (args) =>
|
|
43
|
+
const handler = (args) =>
|
|
44
|
+
queue.push(["unflatten", (sharp) => sharp.unflatten()]);
|
|
42
45
|
|
|
43
46
|
// Exports.
|
|
44
47
|
module.exports = {
|
|
45
|
-
command:
|
|
46
|
-
describe:
|
|
48
|
+
command: "unflatten",
|
|
49
|
+
describe:
|
|
50
|
+
"Ensure the image has an alpha channel with all white pixel values made fully transparent",
|
|
47
51
|
builder,
|
|
48
|
-
handler
|
|
49
|
-
}
|
|
52
|
+
handler,
|
|
53
|
+
};
|
package/cmd/output.js
CHANGED
|
@@ -24,102 +24,110 @@
|
|
|
24
24
|
// @see https://sharp.pixelplumbing.com/api-output#tile
|
|
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 constants = require(
|
|
34
|
-
const queue = require(
|
|
33
|
+
const constants = require("../lib/constants");
|
|
34
|
+
const queue = require("../lib/queue");
|
|
35
35
|
|
|
36
36
|
// Configure.
|
|
37
37
|
const positionals = {
|
|
38
38
|
size: {
|
|
39
|
-
desc:
|
|
39
|
+
desc: "Tile size in pixels",
|
|
40
40
|
defaultDescription: 256,
|
|
41
|
-
type:
|
|
42
|
-
}
|
|
43
|
-
}
|
|
41
|
+
type: "number",
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
44
|
|
|
45
45
|
const options = {
|
|
46
46
|
angle: {
|
|
47
47
|
choices: [0, 90, 180, 270],
|
|
48
|
-
defaultDescription:
|
|
49
|
-
desc:
|
|
48
|
+
defaultDescription: "0",
|
|
49
|
+
desc: "Tile angle of rotation",
|
|
50
50
|
},
|
|
51
51
|
background: {
|
|
52
|
-
defaultDescription:
|
|
53
|
-
desc:
|
|
54
|
-
type:
|
|
52
|
+
defaultDescription: "rgb(255, 255, 255, 1)",
|
|
53
|
+
desc: "Background colour, parsed by the color module",
|
|
54
|
+
type: "string",
|
|
55
55
|
},
|
|
56
56
|
basename: {
|
|
57
|
-
desc:
|
|
58
|
-
type:
|
|
57
|
+
desc: "The name of the directory within the zip file",
|
|
58
|
+
type: "string",
|
|
59
59
|
},
|
|
60
60
|
center: {
|
|
61
|
-
alias:
|
|
62
|
-
desc:
|
|
63
|
-
type:
|
|
61
|
+
alias: "centre",
|
|
62
|
+
desc: "Center images in tile",
|
|
63
|
+
type: "boolean",
|
|
64
64
|
},
|
|
65
65
|
container: {
|
|
66
66
|
choices: constants.CONTAINER,
|
|
67
|
-
defaultDescription:
|
|
68
|
-
desc:
|
|
67
|
+
defaultDescription: "fs",
|
|
68
|
+
desc: "Tile container",
|
|
69
69
|
},
|
|
70
70
|
depth: {
|
|
71
71
|
choices: constants.DEPTH,
|
|
72
|
-
defaultDescription:
|
|
73
|
-
desc:
|
|
72
|
+
defaultDescription: "auto",
|
|
73
|
+
desc: "Pyramid depth",
|
|
74
74
|
},
|
|
75
75
|
id: {
|
|
76
|
-
defaultDescription:
|
|
77
|
-
desc:
|
|
78
|
-
type:
|
|
76
|
+
defaultDescription: "https://example.com/iiif",
|
|
77
|
+
desc: "Set the @id/id attribute of info.json",
|
|
78
|
+
type: "string",
|
|
79
79
|
},
|
|
80
80
|
layout: {
|
|
81
81
|
choices: constants.LAYOUT,
|
|
82
|
-
defaultDescription:
|
|
83
|
-
desc:
|
|
82
|
+
defaultDescription: "dz",
|
|
83
|
+
desc: "Filesystem layout",
|
|
84
84
|
},
|
|
85
85
|
overlap: {
|
|
86
|
-
desc:
|
|
87
|
-
defaultDescription:
|
|
88
|
-
type:
|
|
86
|
+
desc: "Tile overlap in pixels",
|
|
87
|
+
defaultDescription: "0",
|
|
88
|
+
type: "number",
|
|
89
89
|
},
|
|
90
90
|
skipBlanks: {
|
|
91
91
|
defaultDescription: -1,
|
|
92
|
-
desc:
|
|
93
|
-
type:
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const optionNames = Object.keys(options)
|
|
92
|
+
desc: "Threshold to skip tile generation",
|
|
93
|
+
type: "number",
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
const optionNames = Object.keys(options);
|
|
97
97
|
|
|
98
98
|
// Command builder.
|
|
99
99
|
const builder = (yargs) => {
|
|
100
100
|
return yargs
|
|
101
101
|
.strict()
|
|
102
|
-
.example(
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
.example(
|
|
103
|
+
"$0 tile 512",
|
|
104
|
+
"output.dz is the Deep Zoom XML definition, output_files contains 512×512 tiles grouped by zoom level",
|
|
105
|
+
)
|
|
106
|
+
.epilog(
|
|
107
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-output#tile",
|
|
108
|
+
)
|
|
109
|
+
.positional("size", positionals.size)
|
|
105
110
|
.options(options)
|
|
106
|
-
.group(optionNames,
|
|
107
|
-
}
|
|
111
|
+
.group(optionNames, "Command Options");
|
|
112
|
+
};
|
|
108
113
|
|
|
109
114
|
// Command handler.
|
|
110
115
|
const handler = (args) => {
|
|
111
|
-
return queue.push([
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
116
|
+
return queue.push([
|
|
117
|
+
"tile",
|
|
118
|
+
(sharp) => {
|
|
119
|
+
return sharp.tile({
|
|
120
|
+
size: args.size,
|
|
121
|
+
...pick(args, optionNames),
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
]);
|
|
125
|
+
};
|
|
118
126
|
|
|
119
127
|
// Exports.
|
|
120
128
|
module.exports = {
|
|
121
|
-
command:
|
|
122
|
-
describe:
|
|
129
|
+
command: "tile [size]",
|
|
130
|
+
describe: "Use tile-based deep zoom (image pyramid) output",
|
|
123
131
|
builder,
|
|
124
|
-
handler
|
|
125
|
-
}
|
|
132
|
+
handler,
|
|
133
|
+
};
|
package/cmd/resizing/extend.js
CHANGED
|
@@ -21,82 +21,94 @@
|
|
|
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-resize#extend
|
|
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 constants = require(
|
|
34
|
-
const queue = require(
|
|
33
|
+
const constants = require("../../lib/constants");
|
|
34
|
+
const queue = require("../../lib/queue");
|
|
35
35
|
|
|
36
36
|
// Configure.
|
|
37
37
|
const positionals = {
|
|
38
38
|
bottom: {
|
|
39
|
-
desc:
|
|
40
|
-
type:
|
|
39
|
+
desc: "Pixel count to add to the bottom edge",
|
|
40
|
+
type: "number",
|
|
41
41
|
},
|
|
42
42
|
left: {
|
|
43
|
-
desc:
|
|
44
|
-
type:
|
|
43
|
+
desc: "Pixel count to add to the left edge",
|
|
44
|
+
type: "number",
|
|
45
45
|
},
|
|
46
46
|
right: {
|
|
47
|
-
desc:
|
|
48
|
-
type:
|
|
47
|
+
desc: "Pixel count to add to the right edge",
|
|
48
|
+
type: "number",
|
|
49
49
|
},
|
|
50
50
|
top: {
|
|
51
|
-
desc:
|
|
52
|
-
type:
|
|
53
|
-
}
|
|
54
|
-
}
|
|
51
|
+
desc: "Pixel count to add to the top edge",
|
|
52
|
+
type: "number",
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
55
|
|
|
56
56
|
const options = {
|
|
57
57
|
background: {
|
|
58
|
-
defaultDescription:
|
|
59
|
-
desc:
|
|
60
|
-
type:
|
|
58
|
+
defaultDescription: "rgba(0, 0, 0, 1)",
|
|
59
|
+
desc: "Background colour, parsed by the color module",
|
|
60
|
+
type: "string",
|
|
61
61
|
},
|
|
62
62
|
extendWith: {
|
|
63
63
|
choices: constants.EXTEND_WITH,
|
|
64
|
-
default:
|
|
65
|
-
desc:
|
|
66
|
-
}
|
|
67
|
-
}
|
|
64
|
+
default: "background",
|
|
65
|
+
desc: "Populate new pixels using this method",
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
68
|
|
|
69
69
|
// Command builder.
|
|
70
70
|
const builder = (yargs) => {
|
|
71
|
-
const optionNames = Object.keys(options)
|
|
71
|
+
const optionNames = Object.keys(options);
|
|
72
72
|
return yargs
|
|
73
73
|
.strict()
|
|
74
|
-
.example(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
.example(
|
|
75
|
+
"$0 extend 10 20 10 10 --background rgba(0,0,0,0)",
|
|
76
|
+
"Add 10 transparent pixels to the top, left, and right edges, and 20 to the bottom edge",
|
|
77
|
+
)
|
|
78
|
+
.example(
|
|
79
|
+
"$0 extend 0 10 0 0 --background red",
|
|
80
|
+
"Add 10 red pixels to the bottom edge.",
|
|
81
|
+
)
|
|
82
|
+
.epilog(
|
|
83
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-resize#extend",
|
|
84
|
+
)
|
|
85
|
+
.positional("top", positionals.top)
|
|
86
|
+
.positional("bottom", positionals.bottom)
|
|
87
|
+
.positional("left", positionals.left)
|
|
88
|
+
.positional("right", positionals.right)
|
|
81
89
|
.options(options)
|
|
82
|
-
.group(optionNames,
|
|
83
|
-
}
|
|
90
|
+
.group(optionNames, "Command Options");
|
|
91
|
+
};
|
|
84
92
|
|
|
85
93
|
// Command handler.
|
|
86
94
|
const handler = (args) => {
|
|
87
|
-
return queue.push([
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
+
return queue.push([
|
|
96
|
+
"extend",
|
|
97
|
+
(sharp) => {
|
|
98
|
+
return sharp.extend({
|
|
99
|
+
background: args.background,
|
|
100
|
+
extendWith: args.extendWith,
|
|
101
|
+
...pick(args, Object.keys(positionals)),
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
]);
|
|
105
|
+
};
|
|
95
106
|
|
|
96
107
|
// Exports.
|
|
97
108
|
module.exports = {
|
|
98
|
-
command:
|
|
99
|
-
describe:
|
|
109
|
+
command: "extend <top> <bottom> <left> <right>",
|
|
110
|
+
describe:
|
|
111
|
+
"Extends/pads the edges of the image with the provided background colour",
|
|
100
112
|
builder,
|
|
101
|
-
handler
|
|
102
|
-
}
|
|
113
|
+
handler,
|
|
114
|
+
};
|
package/cmd/resizing/extract.js
CHANGED
|
@@ -21,59 +21,64 @@
|
|
|
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-resize#extract
|
|
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 region to extract",
|
|
39
|
+
type: "number",
|
|
40
40
|
},
|
|
41
41
|
left: {
|
|
42
|
-
desc:
|
|
43
|
-
type:
|
|
42
|
+
desc: "Zero-indexed offset from left edge",
|
|
43
|
+
type: "number",
|
|
44
44
|
},
|
|
45
45
|
top: {
|
|
46
|
-
desc:
|
|
47
|
-
type:
|
|
46
|
+
desc: "Zero-indexed offset from top edge",
|
|
47
|
+
type: "number",
|
|
48
48
|
},
|
|
49
49
|
width: {
|
|
50
|
-
desc:
|
|
51
|
-
type:
|
|
52
|
-
}
|
|
53
|
-
}
|
|
50
|
+
desc: "Width of region to extract",
|
|
51
|
+
type: "number",
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
54
|
|
|
55
55
|
// Command builder.
|
|
56
56
|
const builder = (yargs) => {
|
|
57
57
|
return yargs
|
|
58
58
|
.strict()
|
|
59
|
-
.epilog(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.positional(
|
|
63
|
-
.positional(
|
|
64
|
-
|
|
59
|
+
.epilog(
|
|
60
|
+
"For more information on available options, please visit https://sharp.pixelplumbing.com/api-resize#extract",
|
|
61
|
+
)
|
|
62
|
+
.positional("top", positionals.top)
|
|
63
|
+
.positional("left", positionals.left)
|
|
64
|
+
.positional("width", positionals.width)
|
|
65
|
+
.positional("height", positionals.height);
|
|
66
|
+
};
|
|
65
67
|
|
|
66
68
|
// Command handler.
|
|
67
69
|
const handler = (args) => {
|
|
68
|
-
return queue.push([
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
return queue.push([
|
|
71
|
+
"extract",
|
|
72
|
+
(sharp) => {
|
|
73
|
+
return sharp.extract(pick(args, Object.keys(positionals)));
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
};
|
|
72
77
|
|
|
73
78
|
// Exports.
|
|
74
79
|
module.exports = {
|
|
75
|
-
command:
|
|
76
|
-
describe:
|
|
80
|
+
command: "extract <top> <left> <width> <height>",
|
|
81
|
+
describe: "Extract a region of the image",
|
|
77
82
|
builder,
|
|
78
|
-
handler
|
|
79
|
-
}
|
|
83
|
+
handler,
|
|
84
|
+
};
|