@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,101 +24,130 @@
24
24
  // @see https://sharp.pixelplumbing.com/api-resize/
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
  width: {
39
39
  default: null,
40
- desc: 'Pixels wide the resultant image should be',
41
- type: 'number'
40
+ desc: "Pixels wide the resultant image should be",
41
+ type: "number",
42
42
  },
43
43
  height: {
44
44
  default: null,
45
- desc: 'Pixels high the resultant image should be',
46
- type: 'number'
47
- }
48
- }
45
+ desc: "Pixels high the resultant image should be",
46
+ type: "number",
47
+ },
48
+ };
49
49
 
50
50
  const options = {
51
51
  background: {
52
- defaultDescription: 'rgba(0, 0, 0, 1)',
53
- desc: 'Background colour when fit is contain, parsed by the color module.',
54
- type: 'string'
52
+ defaultDescription: "rgba(0, 0, 0, 1)",
53
+ desc: "Background colour when fit is contain, parsed by the color module.",
54
+ type: "string",
55
55
  },
56
56
  fastShrinkOnLoad: {
57
57
  defaultDescription: true,
58
- desc: 'Take greater advantage of the JPEG and WebP shrink-on-load feature',
59
- type: 'boolean'
58
+ desc: "Take greater advantage of the JPEG and WebP shrink-on-load feature",
59
+ type: "boolean",
60
60
  },
61
61
  fit: {
62
62
  choices: constants.FIT,
63
- defaultDescription: 'cover',
64
- desc: 'How the image should be resized to fit both provided dimensions'
63
+ defaultDescription: "cover",
64
+ desc: "How the image should be resized to fit both provided dimensions",
65
65
  },
66
66
  kernel: {
67
67
  choices: constants.KERNEL,
68
- defaultDescription: 'lanczos3',
69
- desc: 'The kernel to use for image reduction and the inferred interpolator to use for upsampling'
68
+ defaultDescription: "lanczos3",
69
+ desc: "The kernel to use for image reduction and the inferred interpolator to use for upsampling",
70
70
  },
71
71
  position: {
72
- choices: [...constants.GRAVITY, ...constants.POSITION, ...constants.STRATEGY],
73
- defaultDescription: 'centre',
74
- desc: 'Position, gravity, or strategy to use when fit is cover or contain'
72
+ choices: [
73
+ ...constants.GRAVITY,
74
+ ...constants.POSITION,
75
+ ...constants.STRATEGY,
76
+ ],
77
+ defaultDescription: "centre",
78
+ desc: "Position, gravity, or strategy to use when fit is cover or contain",
75
79
  },
76
80
  withoutEnlargement: {
77
- desc: 'Do not enlarge if the width or height are already less than the specified dimensions',
78
- type: 'boolean'
81
+ desc: "Do not enlarge if the width or height are already less than the specified dimensions",
82
+ type: "boolean",
79
83
  },
80
84
  withoutReduction: {
81
- desc: 'Do not reduce if the width or height are already greater than the specified dimensions',
82
- type: 'boolean'
83
- }
84
- }
85
- const optionNames = Object.keys(options)
85
+ desc: "Do not reduce if the width or height are already greater than the specified dimensions",
86
+ type: "boolean",
87
+ },
88
+ };
89
+ const optionNames = Object.keys(options);
86
90
 
87
91
  // Command builder.
88
92
  const builder = (yargs) => {
89
93
  return yargs
90
94
  .strict()
91
- .example('$0 resize 100', 'The output will be 100 pixels wide, auto-scaled height')
92
- .example('$0 resize --height 100', 'The output will be 100 pixels high, auto-scaled width')
93
- .example('$0 resize 200 300 --background rgba(255,255,255,0.5) --fit contain --kernel nearest --position "right top"', 'The output will be 200 pixels wide and 300 pixels high containing a nearest-neighbour scaled version contained within the north-east corner of a semi-transparent white canvas')
94
- .example('$0 resize 200 200 --fit cover --position entropy', 'The output will be a 200px square auto-cropped image')
95
- .example('$0 resize 200 200 --withoutEnlargement', 'The output will be no wider and no higher than 200 pixels, and no larger than the input image')
96
- .example('$0 resize 200 200 --withoutReduction', 'The output will be at least 200 pixels wide and 200 pixels high while maintaining aspect ratio, and no smaller than the input image')
97
- .epilog('For more information on available options, please visit https://sharp.pixelplumbing.com/api-resize/')
98
- .positional('width', positionals.width)
99
- .positional('height', positionals.height)
100
- .check(argv => {
95
+ .example(
96
+ "$0 resize 100",
97
+ "The output will be 100 pixels wide, auto-scaled height",
98
+ )
99
+ .example(
100
+ "$0 resize --height 100",
101
+ "The output will be 100 pixels high, auto-scaled width",
102
+ )
103
+ .example(
104
+ '$0 resize 200 300 --background rgba(255,255,255,0.5) --fit contain --kernel nearest --position "right top"',
105
+ "The output will be 200 pixels wide and 300 pixels high containing a nearest-neighbour scaled version contained within the north-east corner of a semi-transparent white canvas",
106
+ )
107
+ .example(
108
+ "$0 resize 200 200 --fit cover --position entropy",
109
+ "The output will be a 200px square auto-cropped image",
110
+ )
111
+ .example(
112
+ "$0 resize 200 200 --withoutEnlargement",
113
+ "The output will be no wider and no higher than 200 pixels, and no larger than the input image",
114
+ )
115
+ .example(
116
+ "$0 resize 200 200 --withoutReduction",
117
+ "The output will be at least 200 pixels wide and 200 pixels high while maintaining aspect ratio, and no smaller than the input image",
118
+ )
119
+ .epilog(
120
+ "For more information on available options, please visit https://sharp.pixelplumbing.com/api-resize/",
121
+ )
122
+ .positional("width", positionals.width)
123
+ .positional("height", positionals.height)
124
+ .check((argv) => {
101
125
  if (argv.width === null && argv.height === null) {
102
- throw new Error('Expected at least one of width and height positionals')
126
+ throw new Error(
127
+ "Expected at least one of width and height positionals",
128
+ );
103
129
  }
104
- return true
130
+ return true;
105
131
  })
106
132
  .options(options)
107
- .group(optionNames, 'Command Options')
108
- }
133
+ .group(optionNames, "Command Options");
134
+ };
109
135
 
110
136
  // Command handler.
111
137
  const handler = (args) => {
112
138
  // @see https://sharp.pixelplumbing.com/api-resize#resize
113
- return queue.push(['resize', (sharp) => {
114
- return sharp.resize(args.width, args.height, pick(args, optionNames))
115
- }])
116
- }
139
+ return queue.push([
140
+ "resize",
141
+ (sharp) => {
142
+ return sharp.resize(args.width, args.height, pick(args, optionNames));
143
+ },
144
+ ]);
145
+ };
117
146
 
118
147
  // Exports.
119
148
  module.exports = {
120
- command: 'resize [width] [height]',
121
- describe: 'Resize image to width, height, or width × height',
149
+ command: "resize [width] [height]",
150
+ describe: "Resize image to width, height, or width × height",
122
151
  builder,
123
- handler
124
- }
152
+ handler,
153
+ };
@@ -21,62 +21,81 @@
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#trim
24
+ // @see https://sharp.pixelplumbing.com/api-resize#trim
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
  threshold: {
35
- desc: 'The allowed difference from the top-left pixel',
35
+ desc: "The allowed difference from the top-left pixel",
36
36
  defaultDescription: 10,
37
- type: 'number'
38
- }
39
- }
37
+ type: "number",
38
+ },
39
+ };
40
40
 
41
41
  const options = {
42
42
  background: {
43
- defaultDescription: 'top-left pixel',
44
- desc: 'Background colour, parsed by the color module',
45
- type: 'string'
43
+ defaultDescription: "top-left pixel",
44
+ desc: "Background colour, parsed by the color module",
45
+ type: "string",
46
46
  },
47
47
  lineArt: {
48
48
  default: false,
49
- desc: 'Does the input more closely resemble line art rather than being photographic',
50
- type: 'boolean'
51
- }
52
- }
49
+ desc: "Does the input more closely resemble line art rather than being photographic",
50
+ type: "boolean",
51
+ },
52
+ };
53
53
 
54
54
  // Command builder.
55
55
  const builder = (yargs) => {
56
- const optionNames = Object.keys(options)
56
+ const optionNames = Object.keys(options);
57
57
  return yargs
58
58
  .strict()
59
- .example('$0 trim', 'Trim pixels with a colour similar to that of the top-left pixel')
60
- .example('$0 trim 0', 'Trim pixels with the exact same colour as that of the top-left pixel')
61
- .example('$0 trim --background "#FF0000"', 'Trim pixels with a similar colour to red')
62
- .example('$0 trim 42 --background yellow', 'Trim all "yellow-ish" pixels')
63
- .epilog('For more information on available options, please visit https://sharp.dimens.io/api-resize#trim')
64
- .positional('threshold', positionals.threshold)
59
+ .example(
60
+ "$0 trim",
61
+ "Trim pixels with a colour similar to that of the top-left pixel",
62
+ )
63
+ .example(
64
+ "$0 trim 0",
65
+ "Trim pixels with the exact same colour as that of the top-left pixel",
66
+ )
67
+ .example(
68
+ '$0 trim --background "#FF0000"',
69
+ "Trim pixels with a similar colour to red",
70
+ )
71
+ .example("$0 trim 42 --background yellow", 'Trim all "yellow-ish" pixels')
72
+ .epilog(
73
+ "For more information on available options, please visit https://sharp.pixelplumbing.com/api-resize#trim",
74
+ )
75
+ .positional("threshold", positionals.threshold)
65
76
  .options(options)
66
- .group(optionNames, 'Command Options')
67
- }
77
+ .group(optionNames, "Command Options");
78
+ };
68
79
 
69
80
  // Command handler.
70
81
  const handler = (args) => {
71
- return queue.push(['trim', (sharp) => {
72
- return sharp.trim({ background: args.background, lineArt: args.lineArt, threshold: args.threshold })
73
- }])
74
- }
82
+ return queue.push([
83
+ "trim",
84
+ (sharp) => {
85
+ return sharp.trim({
86
+ background: args.background,
87
+ lineArt: args.lineArt,
88
+ threshold: args.threshold,
89
+ });
90
+ },
91
+ ]);
92
+ };
75
93
 
76
94
  // Exports.
77
95
  module.exports = {
78
- command: 'trim [threshold]',
79
- describe: 'Trim pixels from all edges that contain values similar to the given background color, which defaults to that of the top-left pixel',
96
+ command: "trim [threshold]",
97
+ describe:
98
+ "Trim pixels from all edges that contain values similar to the given background color, which defaults to that of the top-left pixel",
80
99
  builder,
81
- handler
82
- }
100
+ handler,
101
+ };