@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,39 +24,41 @@
24
24
  // @see https://sharp.pixelplumbing.com/api-operation#median
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
  size: {
35
- desc: 'Square mask size',
35
+ desc: "Square mask size",
36
36
  defaultDescription: 3,
37
- type: 'number'
38
- }
39
- }
37
+ type: "number",
38
+ },
39
+ };
40
40
 
41
41
  // Command builder.
42
42
  const builder = (yargs) => {
43
43
  return yargs
44
44
  .strict()
45
- .example('$0 median')
46
- .example('$0 median 5')
47
- .epilog('For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#median')
48
- .positional('size', positionals.size)
49
- }
45
+ .example("$0 median")
46
+ .example("$0 median 5")
47
+ .epilog(
48
+ "For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#median",
49
+ )
50
+ .positional("size", positionals.size);
51
+ };
50
52
 
51
53
  // Command handler.
52
54
  const handler = (args) => {
53
- return queue.push(['median', (sharp) => sharp.median(args.size)])
54
- }
55
+ return queue.push(["median", (sharp) => sharp.median(args.size)]);
56
+ };
55
57
 
56
58
  // Exports.
57
59
  module.exports = {
58
- command: 'median [size]',
59
- describe: 'Apply median filter',
60
+ command: "median [size]",
61
+ describe: "Apply median filter",
60
62
  builder,
61
- handler
62
- }
63
+ handler,
64
+ };
@@ -24,55 +24,65 @@
24
24
  // @see http://sharp.pixelplumbing.com/api-operation#modulate
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 options = {
37
37
  brightness: {
38
- desc: 'Brightness multiplier',
39
- type: 'number'
38
+ desc: "Brightness multiplier",
39
+ type: "number",
40
40
  },
41
41
  hue: {
42
- desc: 'Degrees for hue rotation',
43
- type: 'number'
42
+ desc: "Degrees for hue rotation",
43
+ type: "number",
44
44
  },
45
45
  lightness: {
46
- desc: 'Lightness addend',
47
- type: 'number'
46
+ desc: "Lightness addend",
47
+ type: "number",
48
48
  },
49
49
  saturation: {
50
- desc: 'Saturation multiplier',
51
- type: 'number'
52
- }
53
- }
54
- const optionNames = Object.keys(options)
50
+ desc: "Saturation multiplier",
51
+ type: "number",
52
+ },
53
+ };
54
+ const optionNames = Object.keys(options);
55
55
 
56
56
  // Command builder.
57
57
  const builder = (yargs) => {
58
58
  return yargs
59
59
  .strict()
60
- .example('$0 modulate --brightness 2', 'Increase brightness by a factor of 2')
61
- .example('$0 modulate --hue 180', 'Hue-rotate by 180 degrees')
62
- .example('$0 modulate --lightness 50', 'Increase lightness by +50')
63
- .example('$0 modulate --brightness 0.5 --saturation 0.5 --hue 90', 'Decrease brightness and saturation while also hue-rotating by 90 degrees')
64
- .epilog('For more information on available options, please visit http://sharp.pixelplumbing.com/api-operation#modulate')
60
+ .example(
61
+ "$0 modulate --brightness 2",
62
+ "Increase brightness by a factor of 2",
63
+ )
64
+ .example("$0 modulate --hue 180", "Hue-rotate by 180 degrees")
65
+ .example("$0 modulate --lightness 50", "Increase lightness by +50")
66
+ .example(
67
+ "$0 modulate --brightness 0.5 --saturation 0.5 --hue 90",
68
+ "Decrease brightness and saturation while also hue-rotating by 90 degrees",
69
+ )
70
+ .epilog(
71
+ "For more information on available options, please visit http://sharp.pixelplumbing.com/api-operation#modulate",
72
+ )
65
73
  .options(options)
66
- .group(optionNames, 'Command Options')
67
- }
74
+ .group(optionNames, "Command Options");
75
+ };
68
76
 
69
77
  // Command handler.
70
- const handler = (args) => queue.push(['modulate', (sharp) => sharp.modulate(pick(args, optionNames))])
78
+ const handler = (args) =>
79
+ queue.push(["modulate", (sharp) => sharp.modulate(pick(args, optionNames))]);
71
80
 
72
81
  // Exports.
73
82
  module.exports = {
74
- command: 'modulate',
75
- describe: 'Transforms the image using brightness, saturation, hue rotation, and lightness',
83
+ command: "modulate",
84
+ describe:
85
+ "Transforms the image using brightness, saturation, hue rotation, and lightness",
76
86
  builder,
77
- handler
78
- }
87
+ handler,
88
+ };
@@ -24,37 +24,40 @@
24
24
  // @see https://sharp.pixelplumbing.com/api-operation#negate
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 options = {
34
34
  alpha: {
35
- desc: 'Whether or not to negate any alpha channel',
36
- type: 'boolean'
37
- }
38
- }
35
+ desc: "Whether or not to negate any alpha channel",
36
+ type: "boolean",
37
+ },
38
+ };
39
39
 
40
40
  // Command builder.
41
41
  const builder = (yargs) => {
42
- const optionNames = Object.keys(options)
42
+ const optionNames = Object.keys(options);
43
43
  return yargs
44
44
  .strict()
45
- .example('$0 negate --no-alpha')
46
- .epilog('For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#negate')
45
+ .example("$0 negate --no-alpha")
46
+ .epilog(
47
+ "For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#negate",
48
+ )
47
49
  .options(options)
48
- .group(optionNames, 'Command Options')
49
- }
50
+ .group(optionNames, "Command Options");
51
+ };
50
52
 
51
53
  // Command handler.
52
- const handler = (args) => queue.push(['negate', (sharp) => sharp.negate(args.alpha)])
54
+ const handler = (args) =>
55
+ queue.push(["negate", (sharp) => sharp.negate(args.alpha)]);
53
56
 
54
57
  // Exports.
55
58
  module.exports = {
56
- command: 'negate',
59
+ command: "negate",
57
60
  describe: 'Produce the "negative" of the image',
58
61
  builder,
59
- handler
60
- }
62
+ handler,
63
+ };
@@ -24,46 +24,53 @@
24
24
  // @see https://sharp.pixelplumbing.com/api-operation#normalise
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
  const options = {
36
36
  lower: {
37
37
  default: 1,
38
- desc: 'Percentile below which luminance values will be underexposed',
39
- type: 'number'
38
+ desc: "Percentile below which luminance values will be underexposed",
39
+ type: "number",
40
40
  },
41
41
  upper: {
42
42
  default: 99,
43
- desc: 'Percentile below which luminance values will be overexposed',
44
- type: 'number'
45
- }
46
- }
47
- const optionNames = Object.keys(options)
43
+ desc: "Percentile below which luminance values will be overexposed",
44
+ type: "number",
45
+ },
46
+ };
47
+ const optionNames = Object.keys(options);
48
48
 
49
49
  // Command builder.
50
50
  const builder = (yargs) => {
51
51
  return yargs
52
52
  .strict()
53
- .epilog('For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#normalise')
54
- .example('$0 normalise')
53
+ .epilog(
54
+ "For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#normalise",
55
+ )
56
+ .example("$0 normalise")
55
57
  .options(options)
56
- .group(optionNames, 'Command Options')
57
- }
58
+ .group(optionNames, "Command Options");
59
+ };
58
60
 
59
61
  // Command handler.
60
- const handler = (args) => queue.push(['normalise', (sharp) => sharp.normalise(pick(args, optionNames))])
62
+ const handler = (args) =>
63
+ queue.push([
64
+ "normalise",
65
+ (sharp) => sharp.normalise(pick(args, optionNames)),
66
+ ]);
61
67
 
62
68
  // Exports.
63
69
  module.exports = {
64
- command: 'normalise',
65
- aliases: 'normalize',
66
- describe: 'Enhance output image contrast by stretching its luminance to cover the full dynamic range',
70
+ command: "normalise",
71
+ aliases: "normalize",
72
+ describe:
73
+ "Enhance output image contrast by stretching its luminance to cover the full dynamic range",
67
74
  builder,
68
- handler
69
- }
75
+ handler,
76
+ };
@@ -21,54 +21,62 @@
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#recomb
24
+ // @see https://sharp.pixelplumbing.com/api-operation#recomb
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 placeholders = {
34
34
  matrix: {
35
- desc: 'Recombination matrix',
35
+ desc: "Recombination matrix",
36
36
  nargs: 3 * 3,
37
- type: 'number'
38
- }
39
- }
37
+ type: "number",
38
+ },
39
+ };
40
40
 
41
41
  // Command builder.
42
42
  const builder = (yargs) => {
43
43
  return yargs
44
44
  .strict()
45
- .example('$0 recomb 0.3588 0.7044 0.1368 0.2990 0.5870 0.1140 0.2392 0.4696 0.0912', 'The recomb will be applied to the output, in this case a sepia filter has been applied')
46
- .epilog('For more information on available options, please visit https://sharp.dimens.io/api-operation#recomb')
47
- .check(argv => {
45
+ .example(
46
+ "$0 recomb 0.3588 0.7044 0.1368 0.2990 0.5870 0.1140 0.2392 0.4696 0.0912",
47
+ "The recomb will be applied to the output, in this case a sepia filter has been applied",
48
+ )
49
+ .epilog(
50
+ "For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#recomb",
51
+ )
52
+ .check((argv) => {
48
53
  if (!(Array.isArray(argv.matrix) && argv.matrix.length === 9)) {
49
- throw new Error('Expected matrix positional to have 9 values')
54
+ throw new Error("Expected matrix positional to have 9 values");
50
55
  }
51
- return true
56
+ return true;
52
57
  })
53
- .positional('matrix', placeholders.matrix)
54
- }
58
+ .positional("matrix", placeholders.matrix);
59
+ };
55
60
 
56
61
  // Command handler.
57
62
  const handler = (args) => {
58
- const { matrix } = args
59
- return queue.push(['recomb', (sharp) => {
60
- return sharp.recomb([
61
- matrix.slice(0, 3),
62
- matrix.slice(3, 6),
63
- matrix.slice(6, 9)
64
- ])
65
- }])
66
- }
63
+ const { matrix } = args;
64
+ return queue.push([
65
+ "recomb",
66
+ (sharp) => {
67
+ return sharp.recomb([
68
+ matrix.slice(0, 3),
69
+ matrix.slice(3, 6),
70
+ matrix.slice(6, 9),
71
+ ]);
72
+ },
73
+ ]);
74
+ };
67
75
 
68
76
  // Exports.
69
77
  module.exports = {
70
- command: 'recomb <matrix..>',
71
- describe: 'Recomb the image with the specified matrix',
78
+ command: "recomb <matrix..>",
79
+ describe: "Recomb the image with the specified matrix",
72
80
  builder,
73
- handler
74
- }
81
+ handler,
82
+ };
@@ -24,49 +24,57 @@
24
24
  // @see https://sharp.pixelplumbing.com/api-operation#rotate
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
  angle: {
35
- defaultDescription: 'auto',
36
- desc: 'Angle of rotation',
37
- type: 'number'
38
- }
39
- }
35
+ defaultDescription: "auto",
36
+ desc: "Angle of rotation",
37
+ type: "number",
38
+ },
39
+ };
40
40
 
41
41
  const options = {
42
42
  background: {
43
- defaultDescription: '#000000',
44
- desc: 'String parsed by the color module to extract values for red, green, blue and alpha',
45
- type: 'string'
46
- }
47
- }
43
+ defaultDescription: "#000000",
44
+ desc: "String parsed by the color module to extract values for red, green, blue and alpha",
45
+ type: "string",
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
- .example('$0 rotate', 'The output will be auto-rotated using EXIF Orientation tag')
55
- .epilog('For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#rotate')
56
- .positional('angle', positionals.angle)
54
+ .example(
55
+ "$0 rotate",
56
+ "The output will be auto-rotated using EXIF Orientation tag",
57
+ )
58
+ .epilog(
59
+ "For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#rotate",
60
+ )
61
+ .positional("angle", positionals.angle)
57
62
  .options(options)
58
- .group(optionNames, 'Command Options')
59
- }
63
+ .group(optionNames, "Command Options");
64
+ };
60
65
 
61
66
  // Command handler.
62
67
  const handler = (args) => {
63
- return queue.push(['rotate', (sharp) => sharp.rotate(args.angle, { background: args.background })])
64
- }
68
+ return queue.push([
69
+ "rotate",
70
+ (sharp) => sharp.rotate(args.angle, { background: args.background }),
71
+ ]);
72
+ };
65
73
 
66
74
  // Exports.
67
75
  module.exports = {
68
- command: 'rotate [angle]',
69
- describe: 'Rotate the output image',
76
+ command: "rotate [angle]",
77
+ describe: "Rotate the output image",
70
78
  builder,
71
- handler
72
- }
79
+ handler,
80
+ };
@@ -24,86 +24,91 @@
24
24
  // @see https://sharp.pixelplumbing.com/api-operation#sharpen
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
  sigma: {
38
- desc: 'The sigma of the Gaussian mask',
39
- defaultDescription: '1 + radius / 2',
40
- type: 'number'
41
- }
42
- }
38
+ desc: "The sigma of the Gaussian mask",
39
+ defaultDescription: "1 + radius / 2",
40
+ type: "number",
41
+ },
42
+ };
43
43
 
44
44
  const options = {
45
45
  m1: {
46
- alias: 'flat',
46
+ alias: "flat",
47
47
  desc: 'The level of sharpening to apply to "flat" areas',
48
48
  defaultDescription: 1.0,
49
- type: 'number'
49
+ type: "number",
50
50
  },
51
51
  m2: {
52
- alias: 'jagged',
52
+ alias: "jagged",
53
53
  desc: 'The level of sharpening to apply to "jagged" areas',
54
54
  defaultDescription: 2.0,
55
- type: 'number'
55
+ type: "number",
56
56
  },
57
57
  x1: {
58
58
  desc: 'The threshold between "flat" and "jagged" areas',
59
59
  defaultDescription: 2.0,
60
- type: 'number'
60
+ type: "number",
61
61
  },
62
62
  y2: {
63
- desc: 'The maximum amount of brightening',
63
+ desc: "The maximum amount of brightening",
64
64
  defaultDescription: 10.0,
65
- type: 'number'
65
+ type: "number",
66
66
  },
67
67
  y3: {
68
- desc: 'The maximum amount of darkening',
68
+ desc: "The maximum amount of darkening",
69
69
  defaultDescription: 20.0,
70
- type: 'number'
71
- }
72
- }
73
- const optionNames = Object.keys(options)
70
+ type: "number",
71
+ },
72
+ };
73
+ const optionNames = Object.keys(options);
74
74
 
75
75
  // Command builder.
76
76
  const builder = (yargs) => {
77
77
  return yargs
78
78
  .strict()
79
- .example('$0 sharpen')
80
- .example('$0 sharpen 2')
81
- .example('$0 sharpen 2 --m1 0 --m2 3 --x1 3 --y2 15 --y3 15')
82
- .epilog('For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#sharpen')
83
- .positional('sigma', positionals.sigma)
79
+ .example("$0 sharpen")
80
+ .example("$0 sharpen 2")
81
+ .example("$0 sharpen 2 --m1 0 --m2 3 --x1 3 --y2 15 --y3 15")
82
+ .epilog(
83
+ "For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#sharpen",
84
+ )
85
+ .positional("sigma", positionals.sigma)
84
86
  .options(options)
85
- .group(optionNames, 'Command Options')
86
- }
87
+ .group(optionNames, "Command Options");
88
+ };
87
89
 
88
90
  // Command handler.
89
91
  const handler = (args) => {
90
92
  const options = {
91
93
  ...pick(args, Object.keys(positionals)),
92
- ...pick(args, optionNames)
93
- }
94
+ ...pick(args, optionNames),
95
+ };
94
96
 
95
- return queue.push(['sharpen', (sharp) => {
96
- if (Object.keys(options).length === 0) {
97
- return sharp.sharpen()
98
- }
99
- return sharp.sharpen(options)
100
- }])
101
- }
97
+ return queue.push([
98
+ "sharpen",
99
+ (sharp) => {
100
+ if (Object.keys(options).length === 0) {
101
+ return sharp.sharpen();
102
+ }
103
+ return sharp.sharpen(options);
104
+ },
105
+ ]);
106
+ };
102
107
 
103
108
  // Exports.
104
109
  module.exports = {
105
- command: 'sharpen [sigma]',
106
- describe: 'Sharpen the image',
110
+ command: "sharpen [sigma]",
111
+ describe: "Sharpen the image",
107
112
  builder,
108
- handler
109
- }
113
+ handler,
114
+ };