@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.
Files changed (48) hide show
  1. package/.prettierignore +2 -0
  2. package/.prettierrc +1 -0
  3. package/CHANGELOG.md +20 -8
  4. package/README.md +5 -5
  5. package/bin/cli.js +3 -3
  6. package/changes.json +5 -5
  7. package/cmd/channel-manipulation/bandbool.js +22 -16
  8. package/cmd/channel-manipulation/ensure-alpha.js +25 -17
  9. package/cmd/channel-manipulation/extract-channel.js +24 -16
  10. package/cmd/channel-manipulation/join-channel.js +17 -15
  11. package/cmd/channel-manipulation/remove-alpha.js +13 -10
  12. package/cmd/colour-manipulation/greyscale.js +17 -11
  13. package/cmd/colour-manipulation/pipeline-colourspace.js +26 -18
  14. package/cmd/colour-manipulation/tint.js +17 -14
  15. package/cmd/colour-manipulation/tocolourspace.js +23 -18
  16. package/cmd/compositing/composite.js +127 -99
  17. package/cmd/operations/affine.js +53 -45
  18. package/cmd/operations/blur.js +44 -36
  19. package/cmd/operations/boolean.js +23 -18
  20. package/cmd/operations/clahe.js +36 -31
  21. package/cmd/operations/convolve.js +51 -43
  22. package/cmd/operations/dilate.js +64 -0
  23. package/cmd/operations/erode.js +64 -0
  24. package/cmd/operations/flatten.js +24 -19
  25. package/cmd/operations/flip.js +12 -10
  26. package/cmd/operations/flop.js +12 -10
  27. package/cmd/operations/gamma.js +27 -20
  28. package/cmd/operations/linear.js +31 -24
  29. package/cmd/operations/median.js +19 -17
  30. package/cmd/operations/modulate.js +36 -26
  31. package/cmd/operations/negate.js +18 -15
  32. package/cmd/operations/normalise.js +27 -20
  33. package/cmd/operations/recomb.js +35 -27
  34. package/cmd/operations/rotate.js +32 -24
  35. package/cmd/operations/sharpen.js +45 -40
  36. package/cmd/operations/threshold.js +30 -24
  37. package/cmd/operations/unflatten.js +15 -11
  38. package/cmd/output.js +59 -51
  39. package/cmd/resizing/extend.js +56 -44
  40. package/cmd/resizing/extract.js +33 -28
  41. package/cmd/resizing/resize.js +80 -51
  42. package/cmd/resizing/trim.js +50 -31
  43. package/lib/cli.js +480 -366
  44. package/lib/constants.js +23 -15
  45. package/lib/convert.js +47 -52
  46. package/lib/index.js +23 -19
  47. package/lib/queue.js +8 -7
  48. 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
- 'use strict'
27
+ "use strict";
28
28
 
29
29
  // Local modules.
30
- const queue = require('../../lib/queue')
30
+ const queue = require("../../lib/queue");
31
31
 
32
32
  // Configure.
33
33
  const positionals = {
34
34
  value: {
35
- desc: 'A value in the range 0-255 representing the level at which the threshold will be applied',
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: 'number'
38
- }
39
- }
37
+ type: "number",
38
+ },
39
+ };
40
40
 
41
41
  const options = {
42
42
  greyscale: {
43
- alias: 'grayscale',
44
- desc: 'Convert to single channel greyscale',
45
- type: 'boolean'
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('For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#threshold')
55
- .positional('value', positionals.value)
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, 'Command Options')
58
- }
59
+ .group(optionNames, "Command Options");
60
+ };
59
61
 
60
62
  // Command handler.
61
63
  const handler = (args) => {
62
- return queue.push(['threshold', (sharp) => {
63
- return sharp.threshold(args.value, { greyscale: args.greyscale })
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: 'threshold [value]',
70
- describe: 'Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0',
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.dimens.io/api-operation#unflatten
24
+ // @see https://sharp.pixelplumbing.com/api-operation#unflatten
25
25
 
26
26
  // Strict mode.
27
- 'use strict'
27
+ "use strict";
28
28
 
29
29
  // Local modules.
30
- const queue = require('../../lib/queue')
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('$0 unflatten')
37
- .epilog('For more information on available options, please visit https://sharp.dimens.io/api-operation#unflatten')
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) => queue.push(['unflatten', (sharp) => sharp.unflatten()])
43
+ const handler = (args) =>
44
+ queue.push(["unflatten", (sharp) => sharp.unflatten()]);
42
45
 
43
46
  // Exports.
44
47
  module.exports = {
45
- command: 'unflatten',
46
- describe: 'Ensure the image has an alpha channel with all white pixel values made fully transparent',
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
- 'use strict'
27
+ "use strict";
28
28
 
29
29
  // Package modules.
30
- const pick = require('lodash.pick')
30
+ const pick = require("lodash.pick");
31
31
 
32
32
  // Local modules.
33
- const constants = require('../lib/constants')
34
- const queue = require('../lib/queue')
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: 'Tile size in pixels',
39
+ desc: "Tile size in pixels",
40
40
  defaultDescription: 256,
41
- type: 'number'
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: '0',
49
- desc: 'Tile angle of rotation'
48
+ defaultDescription: "0",
49
+ desc: "Tile angle of rotation",
50
50
  },
51
51
  background: {
52
- defaultDescription: 'rgb(255, 255, 255, 1)',
53
- desc: 'Background colour, parsed by the color module',
54
- type: 'string'
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: 'The name of the directory within the zip file',
58
- type: 'string'
57
+ desc: "The name of the directory within the zip file",
58
+ type: "string",
59
59
  },
60
60
  center: {
61
- alias: 'centre',
62
- desc: 'Center images in tile',
63
- type: 'boolean'
61
+ alias: "centre",
62
+ desc: "Center images in tile",
63
+ type: "boolean",
64
64
  },
65
65
  container: {
66
66
  choices: constants.CONTAINER,
67
- defaultDescription: 'fs',
68
- desc: 'Tile container'
67
+ defaultDescription: "fs",
68
+ desc: "Tile container",
69
69
  },
70
70
  depth: {
71
71
  choices: constants.DEPTH,
72
- defaultDescription: 'auto',
73
- desc: 'Pyramid depth'
72
+ defaultDescription: "auto",
73
+ desc: "Pyramid depth",
74
74
  },
75
75
  id: {
76
- defaultDescription: 'https://example.com/iiif',
77
- desc: 'Set the @id/id attribute of info.json',
78
- type: 'string'
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: 'dz',
83
- desc: 'Filesystem layout'
82
+ defaultDescription: "dz",
83
+ desc: "Filesystem layout",
84
84
  },
85
85
  overlap: {
86
- desc: 'Tile overlap in pixels',
87
- defaultDescription: '0',
88
- type: 'number'
86
+ desc: "Tile overlap in pixels",
87
+ defaultDescription: "0",
88
+ type: "number",
89
89
  },
90
90
  skipBlanks: {
91
91
  defaultDescription: -1,
92
- desc: 'Threshold to skip tile generation',
93
- type: 'number'
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('$0 tile 512', 'output.dz is the Deep Zoom XML definition, output_files contains 512×512 tiles grouped by zoom level')
103
- .epilog('For more information on available options, please visit https://sharp.pixelplumbing.com/api-output#tile')
104
- .positional('size', positionals.size)
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, 'Command Options')
107
- }
111
+ .group(optionNames, "Command Options");
112
+ };
108
113
 
109
114
  // Command handler.
110
115
  const handler = (args) => {
111
- return queue.push(['tile', (sharp) => {
112
- return sharp.tile({
113
- size: args.size,
114
- ...pick(args, optionNames)
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: 'tile [size]',
122
- describe: 'Use tile-based deep zoom (image pyramid) output',
129
+ command: "tile [size]",
130
+ describe: "Use tile-based deep zoom (image pyramid) output",
123
131
  builder,
124
- handler
125
- }
132
+ handler,
133
+ };
@@ -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.dimens.io/api-resize#extend
24
+ // @see https://sharp.pixelplumbing.com/api-resize#extend
25
25
 
26
26
  // Strict mode.
27
- 'use strict'
27
+ "use strict";
28
28
 
29
29
  // Package modules.
30
- const pick = require('lodash.pick')
30
+ const pick = require("lodash.pick");
31
31
 
32
32
  // Local modules.
33
- const constants = require('../../lib/constants')
34
- const queue = require('../../lib/queue')
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: 'Pixel count to add to the bottom edge',
40
- type: 'number'
39
+ desc: "Pixel count to add to the bottom edge",
40
+ type: "number",
41
41
  },
42
42
  left: {
43
- desc: 'Pixel count to add to the left edge',
44
- type: 'number'
43
+ desc: "Pixel count to add to the left edge",
44
+ type: "number",
45
45
  },
46
46
  right: {
47
- desc: 'Pixel count to add to the right edge',
48
- type: 'number'
47
+ desc: "Pixel count to add to the right edge",
48
+ type: "number",
49
49
  },
50
50
  top: {
51
- desc: 'Pixel count to add to the top edge',
52
- type: 'number'
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: 'rgba(0, 0, 0, 1)',
59
- desc: 'Background colour, parsed by the color module',
60
- type: 'string'
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: 'background',
65
- desc: 'Populate new pixels using this method'
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('$0 extend 10 20 10 10 --background rgba(0,0,0,0)', 'Add 10 transparent pixels to the top, left, and right edges, and 20 to the bottom edge')
75
- .example('$0 extend 0 10 0 0 --background red', 'Add 10 red pixels to the bottom edge.')
76
- .epilog('For more information on available options, please visit https://sharp.dimens.io/api-resize#extend')
77
- .positional('top', positionals.top)
78
- .positional('bottom', positionals.bottom)
79
- .positional('left', positionals.left)
80
- .positional('right', positionals.right)
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, 'Command Options')
83
- }
90
+ .group(optionNames, "Command Options");
91
+ };
84
92
 
85
93
  // Command handler.
86
94
  const handler = (args) => {
87
- return queue.push(['extend', (sharp) => {
88
- return sharp.extend({
89
- background: args.background,
90
- extendWith: args.extendWith,
91
- ...pick(args, Object.keys(positionals))
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: 'extend <top> <bottom> <left> <right>',
99
- describe: 'Extends/pads the edges of the image with the provided background colour',
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
+ };
@@ -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.dimens.io/api-resize#extract
24
+ // @see https://sharp.pixelplumbing.com/api-resize#extract
25
25
 
26
26
  // Strict mode.
27
- 'use strict'
27
+ "use strict";
28
28
 
29
29
  // Package modules.
30
- const pick = require('lodash.pick')
30
+ const pick = require("lodash.pick");
31
31
 
32
32
  // Local modules.
33
- const queue = require('../../lib/queue')
33
+ const queue = require("../../lib/queue");
34
34
 
35
35
  // Configure.
36
36
  const positionals = {
37
37
  height: {
38
- desc: 'Height of region to extract',
39
- type: 'number'
38
+ desc: "Height of region to extract",
39
+ type: "number",
40
40
  },
41
41
  left: {
42
- desc: 'Zero-indexed offset from left edge',
43
- type: 'number'
42
+ desc: "Zero-indexed offset from left edge",
43
+ type: "number",
44
44
  },
45
45
  top: {
46
- desc: 'Zero-indexed offset from top edge',
47
- type: 'number'
46
+ desc: "Zero-indexed offset from top edge",
47
+ type: "number",
48
48
  },
49
49
  width: {
50
- desc: 'Width of region to extract',
51
- type: 'number'
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('For more information on available options, please visit https://sharp.dimens.io/api-resize#extract')
60
- .positional('top', positionals.top)
61
- .positional('left', positionals.left)
62
- .positional('width', positionals.width)
63
- .positional('height', positionals.height)
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(['extract', (sharp) => {
69
- return sharp.extract(pick(args, Object.keys(positionals)))
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: 'extract <top> <left> <width> <height>',
76
- describe: 'Extract a region of the image',
80
+ command: "extract <top> <left> <width> <height>",
81
+ describe: "Extract a region of the image",
77
82
  builder,
78
- handler
79
- }
83
+ handler,
84
+ };