@depup/sharp-cli 5.3.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.
Files changed (48) hide show
  1. package/.github/workflows/ci.yml +30 -0
  2. package/CHANGELOG.md +20 -0
  3. package/README.md +6 -9
  4. package/bin/cli.js +5 -5
  5. package/changes.json +4 -16
  6. package/cmd/channel-manipulation/bandbool.js +6 -7
  7. package/cmd/channel-manipulation/ensure-alpha.js +5 -8
  8. package/cmd/channel-manipulation/extract-channel.js +3 -7
  9. package/cmd/channel-manipulation/join-channel.js +5 -8
  10. package/cmd/channel-manipulation/remove-alpha.js +2 -8
  11. package/cmd/colour-manipulation/greyscale.js +2 -8
  12. package/cmd/colour-manipulation/pipeline-colourspace.js +4 -8
  13. package/cmd/colour-manipulation/tint.js +3 -8
  14. package/cmd/colour-manipulation/tocolourspace.js +3 -7
  15. package/cmd/compositing/composite.js +10 -7
  16. package/cmd/operations/affine.js +9 -11
  17. package/cmd/operations/blur.js +3 -8
  18. package/cmd/operations/boolean.js +3 -7
  19. package/cmd/operations/clahe.js +4 -9
  20. package/cmd/operations/convolve.js +5 -9
  21. package/cmd/operations/dilate.js +2 -8
  22. package/cmd/operations/erode.js +2 -8
  23. package/cmd/operations/flatten.js +2 -8
  24. package/cmd/operations/flip.js +3 -8
  25. package/cmd/operations/flop.js +3 -8
  26. package/cmd/operations/gamma.js +2 -8
  27. package/cmd/operations/linear.js +2 -8
  28. package/cmd/operations/median.js +2 -8
  29. package/cmd/operations/modulate.js +10 -9
  30. package/cmd/operations/negate.js +2 -8
  31. package/cmd/operations/normalise.js +5 -9
  32. package/cmd/operations/recomb.js +2 -8
  33. package/cmd/operations/rotate.js +2 -8
  34. package/cmd/operations/sharpen.js +8 -9
  35. package/cmd/operations/threshold.js +2 -8
  36. package/cmd/operations/unflatten.js +2 -8
  37. package/cmd/output.js +7 -10
  38. package/cmd/resizing/extend.js +4 -10
  39. package/cmd/resizing/extract.js +3 -9
  40. package/cmd/resizing/resize.js +4 -10
  41. package/cmd/resizing/trim.js +12 -8
  42. package/{lib/queue.js → eslint.config.mjs} +20 -17
  43. package/lib/cli.js +473 -333
  44. package/lib/constants.js +4 -6
  45. package/lib/convert.js +93 -55
  46. package/lib/index.js +46 -17
  47. package/lib/utils.js +50 -0
  48. package/package.json +24 -33
@@ -23,14 +23,8 @@
23
23
 
24
24
  // @see https://sharp.pixelplumbing.com/api-resize#extract
25
25
 
26
- // Strict mode.
27
- "use strict";
28
-
29
- // Package modules.
30
- const pick = require("lodash.pick");
31
-
32
26
  // Local modules.
33
- const queue = require("../../lib/queue");
27
+ import { pick } from "../../lib/utils.js";
34
28
 
35
29
  // Configure.
36
30
  const positionals = {
@@ -67,7 +61,7 @@ const builder = (yargs) => {
67
61
 
68
62
  // Command handler.
69
63
  const handler = (args) => {
70
- return queue.push([
64
+ return args["#queue"].push([
71
65
  "extract",
72
66
  (sharp) => {
73
67
  return sharp.extract(pick(args, Object.keys(positionals)));
@@ -76,7 +70,7 @@ const handler = (args) => {
76
70
  };
77
71
 
78
72
  // Exports.
79
- module.exports = {
73
+ export default {
80
74
  command: "extract <top> <left> <width> <height>",
81
75
  describe: "Extract a region of the image",
82
76
  builder,
@@ -23,15 +23,9 @@
23
23
 
24
24
  // @see https://sharp.pixelplumbing.com/api-resize/
25
25
 
26
- // Strict mode.
27
- "use strict";
28
-
29
- // Package modules.
30
- const pick = require("lodash.pick");
31
-
32
26
  // Local modules.
33
- const constants = require("../../lib/constants");
34
- const queue = require("../../lib/queue");
27
+ import constants from "../../lib/constants.js";
28
+ import { pick } from "../../lib/utils.js";
35
29
 
36
30
  // Configure.
37
31
  const positionals = {
@@ -136,7 +130,7 @@ const builder = (yargs) => {
136
130
  // Command handler.
137
131
  const handler = (args) => {
138
132
  // @see https://sharp.pixelplumbing.com/api-resize#resize
139
- return queue.push([
133
+ return args["#queue"].push([
140
134
  "resize",
141
135
  (sharp) => {
142
136
  return sharp.resize(args.width, args.height, pick(args, optionNames));
@@ -145,7 +139,7 @@ const handler = (args) => {
145
139
  };
146
140
 
147
141
  // Exports.
148
- module.exports = {
142
+ export default {
149
143
  command: "resize [width] [height]",
150
144
  describe: "Resize image to width, height, or width × height",
151
145
  builder,
@@ -23,12 +23,6 @@
23
23
 
24
24
  // @see https://sharp.pixelplumbing.com/api-resize#trim
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
  threshold: {
@@ -49,6 +43,11 @@ const options = {
49
43
  desc: "Does the input more closely resemble line art rather than being photographic",
50
44
  type: "boolean",
51
45
  },
46
+ margin: {
47
+ desc: "Leave a margin around trimmed content",
48
+ nargs: 1,
49
+ type: "number",
50
+ },
52
51
  };
53
52
 
54
53
  // Command builder.
@@ -69,6 +68,10 @@ const builder = (yargs) => {
69
68
  "Trim pixels with a similar colour to red",
70
69
  )
71
70
  .example("$0 trim 42 --background yellow", 'Trim all "yellow-ish" pixels')
71
+ .example(
72
+ "$0 trim --margin 10",
73
+ "Trim image leaving (up to) 10 pixel margin around the trimmed content",
74
+ )
72
75
  .epilog(
73
76
  "For more information on available options, please visit https://sharp.pixelplumbing.com/api-resize#trim",
74
77
  )
@@ -79,12 +82,13 @@ const builder = (yargs) => {
79
82
 
80
83
  // Command handler.
81
84
  const handler = (args) => {
82
- return queue.push([
85
+ return args["#queue"].push([
83
86
  "trim",
84
87
  (sharp) => {
85
88
  return sharp.trim({
86
89
  background: args.background,
87
90
  lineArt: args.lineArt,
91
+ margin: args.margin,
88
92
  threshold: args.threshold,
89
93
  });
90
94
  },
@@ -92,7 +96,7 @@ const handler = (args) => {
92
96
  };
93
97
 
94
98
  // Exports.
95
- module.exports = {
99
+ export default {
96
100
  command: "trim [threshold]",
97
101
  describe:
98
102
  "Trim pixels from all edges that contain values similar to the given background color, which defaults to that of the top-left pixel",
@@ -21,25 +21,28 @@
21
21
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- // Strict mode.
25
- "use strict";
24
+ // Package modules.
25
+ import js from "@eslint/js";
26
+ import globals from "globals";
27
+ import { defineConfig, globalIgnores } from "eslint/config";
26
28
 
27
- // Configure.
28
- const queue = [];
29
+ // Exports.
30
+ export default defineConfig([
31
+ globalIgnores(["coverage/**", ".nyc_output/**"]),
32
+ js.configs.recommended,
29
33
 
30
- // Extend object.
31
- Object.defineProperties(queue, {
32
- // Add drain handler.
33
- drain: {
34
- value: (initialValue) =>
35
- queue.reduce((acc, [, cb]) => cb(acc), initialValue),
34
+ {
35
+ files: ["**/*.{js,mjs,cjs}"],
36
+ languageOptions: { globals: globals.node },
36
37
  },
37
38
 
38
- // Add pipeline getter.
39
- pipeline: {
40
- get: () => queue.map(([value]) => value),
39
+ {
40
+ files: ["test/**/*.js"],
41
+ languageOptions: {
42
+ globals: {
43
+ ...globals.node,
44
+ ...globals.mocha,
45
+ },
46
+ },
41
47
  },
42
- });
43
-
44
- // Exports.
45
- module.exports = queue;
48
+ ]);