@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
package/lib/constants.js CHANGED
@@ -22,34 +22,42 @@
22
22
  */
23
23
 
24
24
  // Strict mode.
25
- 'use strict'
25
+ "use strict";
26
26
 
27
27
  // Package modules.
28
- const sharp = require('sharp')
28
+ const sharp = require("sharp");
29
29
 
30
30
  // Exports.
31
31
  module.exports = {
32
32
  BLEND: Object.keys(sharp.blend),
33
33
  BOOL: Object.keys(sharp.bool),
34
- CHANNEL: ['red', 'green', 'blue', 'alpha'],
34
+ CHANNEL: ["red", "green", "blue", "alpha"],
35
35
  COLOURSPACE: Object.keys(sharp.colourspace),
36
- CONTAINER: ['fs', 'zip'],
37
- DEPTH: ['onepixel', 'onetile', 'one'],
38
- EXTEND_WITH: ['background', 'copy', 'repeat', 'mirror'],
39
- FAIL_ON: ['none', 'truncated', 'error', 'warning'],
36
+ CONTAINER: ["fs", "zip"],
37
+ DEPTH: ["onepixel", "onetile", "one"],
38
+ EXTEND_WITH: ["background", "copy", "repeat", "mirror"],
39
+ FAIL_ON: ["none", "truncated", "error", "warning"],
40
40
  FIT: Object.keys(sharp.fit),
41
- FORMAT: ['avif', 'gif', 'heif', 'jpeg', 'jpg', 'png', 'raw', 'tiff', 'webp'],
41
+ FORMAT: ["avif", "gif", "heif", "jpeg", "jpg", "png", "tiff", "webp"],
42
42
  GRAVITY: Object.keys(sharp.gravity),
43
- HEIF_COMPRESSION: ['hevc', 'av1'],
43
+ HEIF_COMPRESSION: ["hevc", "av1"],
44
44
  INTERPOLATORS: Object.keys(sharp.interpolators),
45
45
  KERNEL: Object.keys(sharp.kernel),
46
- LAYOUT: ['dz', 'google', 'iiif', 'zoomify'],
46
+ LAYOUT: ["dz", "google", "iiif", "iiif3", "zoomify"],
47
47
  POSITION: Object.keys(sharp.position),
48
- PRESETS: ['default', 'photo', 'picture', 'drawing', 'icon', 'text'],
49
- RESOLUTION_UNIT: ['cm', 'inch'],
48
+ PRESETS: ["default", "photo", "picture", "drawing", "icon", "text"],
49
+ RESOLUTION_UNIT: ["cm", "inch"],
50
50
  STRATEGY: Object.keys(sharp.strategy),
51
51
  TIFF_COMPRESSION: [
52
- 'ccittfax4', 'deflate', 'jpeg', 'jp2k', 'lzw', 'none', 'packbits', 'webp', 'zstd'
52
+ "ccittfax4",
53
+ "deflate",
54
+ "jpeg",
55
+ "jp2k",
56
+ "lzw",
57
+ "none",
58
+ "packbits",
59
+ "webp",
60
+ "zstd",
53
61
  ],
54
- TIFF_PREDICTOR: ['float', 'horizontal', 'none']
55
- }
62
+ TIFF_PREDICTOR: ["float", "horizontal", "none"],
63
+ };
package/lib/convert.js CHANGED
@@ -22,32 +22,32 @@
22
22
  */
23
23
 
24
24
  // Strict mode.
25
- 'use strict'
25
+ "use strict";
26
26
 
27
27
  // Standard lib.
28
- const fs = require('fs')
29
- const path = require('path')
28
+ const fs = require("fs");
29
+ const path = require("path");
30
+ const { pipeline } = require("stream/promises");
30
31
 
31
32
  // Package modules.
32
- const bubbleError = require('bubble-stream-error')
33
- const { globSync } = require('glob')
34
- const isDirectory = require('is-directory')
35
- const sharp = require('sharp')
33
+ const { globSync } = require("glob");
34
+ const isDirectory = require("is-directory");
35
+ const sharp = require("sharp");
36
36
 
37
37
  // Local modules.
38
- const queue = require('./queue')
38
+ const queue = require("./queue");
39
39
 
40
40
  // Configure.
41
41
  const EXTENSIONS = {
42
- avif: '.avif',
43
- dz: '', // Determined by tile.container.
44
- gif: '.gif',
45
- heif: '.avif',
46
- jpeg: '.jpg',
47
- png: '.png',
48
- tiff: '.tiff',
49
- webp: '.webp'
50
- }
42
+ avif: ".avif",
43
+ dz: "", // Determined by tile.container.
44
+ gif: ".gif",
45
+ heif: ".avif",
46
+ jpeg: ".jpg",
47
+ png: ".png",
48
+ tiff: ".tiff",
49
+ webp: ".webp",
50
+ };
51
51
 
52
52
  // Exports.
53
53
  module.exports = {
@@ -55,67 +55,62 @@ module.exports = {
55
55
  files: (input, output, options) => {
56
56
  // Resolve files.
57
57
  const files = input.reduce((list, input) => {
58
- return list.concat(globSync(input, { absolute: true }))
59
- }, [])
58
+ return list.concat(globSync(input, { absolute: true }));
59
+ }, []);
60
60
 
61
61
  if (files.length === 0) {
62
- return Promise.reject(new Error('No input files'))
62
+ return Promise.reject(new Error("No input files"));
63
63
  }
64
64
 
65
65
  // Process files.
66
- const isBatch = files.length > 1
66
+ const isBatch = files.length > 1;
67
67
  const promises = files.map((src) => {
68
68
  // Create pipeline.
69
- const transformer = queue.drain(sharp(options))
69
+ const transformer = queue.drain(sharp(options));
70
70
 
71
71
  // Process output as a template.
72
- const parts = path.parse(src)
73
- const regex = /\{(root|dir|base|ext|name)\}/g
74
- let dest = output
75
- let match
72
+ const parts = path.parse(src);
73
+ const regex = /\{(root|dir|base|ext|name)\}/g;
74
+ let dest = output;
75
+ let match;
76
76
  while ((match = regex.exec(output)) !== null) {
77
- const [search, prop] = match
78
- dest = dest.replace(search, parts[prop])
77
+ const [search, prop] = match;
78
+ dest = dest.replace(search, parts[prop]);
79
79
  }
80
- dest = path.resolve(dest)
80
+ dest = path.resolve(dest);
81
81
 
82
82
  // If output was not a template, assume dest is a directory when using
83
83
  // batch processing.
84
- const outputAssumeDir = dest === path.resolve(output) && isBatch
84
+ const outputAssumeDir = dest === path.resolve(output) && isBatch;
85
85
  if (outputAssumeDir || isDirectory.sync(dest)) {
86
- const defaultExt = path.extname(src)
87
- const desiredExt = transformer.options.formatOut
86
+ const defaultExt = path.extname(src);
87
+ const desiredExt = transformer.options.formatOut;
88
88
  dest = path.format({
89
89
  dir: dest,
90
90
  name: path.basename(src, defaultExt),
91
- ext: desiredExt in EXTENSIONS ? EXTENSIONS[desiredExt] : defaultExt
92
- })
91
+ ext: desiredExt in EXTENSIONS ? EXTENSIONS[desiredExt] : defaultExt,
92
+ });
93
93
  }
94
94
 
95
95
  // Write, attach info and return.
96
- fs.createReadStream(src).pipe(transformer)
96
+ fs.createReadStream(src).pipe(transformer);
97
97
  return transformer
98
98
  .toFile(dest)
99
- .then((info) => Object.assign(info, { src, path: dest }))
100
- })
101
- return Promise.all(promises)
99
+ .then((info) => Object.assign(info, { src, path: dest }));
100
+ });
101
+ return Promise.all(promises);
102
102
  },
103
103
 
104
104
  // Convert a stream.
105
105
  stream: (inStream, outStream, options) => {
106
- return new Promise((resolve, reject) => {
107
- // Create pipeline.
108
- const transformer = queue.drain(sharp(options))
106
+ // Create pipeline.
107
+ const transformer = queue.drain(sharp(options));
109
108
 
110
- // Gather return value.
111
- const info = { }
112
- transformer.on('info', (_info) => Object.assign(info, _info))
109
+ // Gather return value.
110
+ const info = {};
111
+ transformer.on("info", (_info) => Object.assign(info, _info));
113
112
 
114
- // Pipe, and return as promise.
115
- bubbleError(inStream, transformer, outStream)
116
- inStream.pipe(transformer).pipe(outStream)
117
- outStream.once('error', reject)
118
- outStream.on('finish', () => resolve(info))
119
- })
120
- }
121
- }
113
+ // Pipe, and return as promise.
114
+ return pipeline(inStream, transformer, outStream).then(() => info);
115
+ },
116
+ };
package/lib/index.js CHANGED
@@ -22,37 +22,41 @@
22
22
  */
23
23
 
24
24
  // Strict mode.
25
- 'use strict'
25
+ "use strict";
26
26
 
27
27
  // Package modules.
28
- const pick = require('lodash.pick')
28
+ const pick = require("lodash.pick");
29
29
 
30
30
  // Local modules.
31
- const cli = require('./cli')
32
- const convert = require('./convert')
31
+ const cli = require("./cli");
32
+ const convert = require("./convert");
33
33
 
34
34
  // Exports.
35
- module.exports = (args, options = { }) => {
36
- const logger = options.logger || console // Cast.
35
+ module.exports = (args, options = {}) => {
36
+ const logger = options.logger || console; // Cast.
37
37
 
38
38
  // Parse arguments and handle i/o.
39
- return cli.parse(args)
40
- .then(argv => {
41
- const options = pick(argv, cli.inputOptions)
39
+ return cli
40
+ .parse(args)
41
+ .then((argv) => {
42
+ const options = pick(argv, cli.inputOptions);
42
43
  if (argv.input) {
43
- return convert.files(argv.input, argv.output, options)
44
+ return convert.files(argv.input, argv.output, options);
44
45
  }
45
- return convert.stream(process.stdin, process.stdout, options)
46
+ return convert.stream(process.stdin, process.stdout, options);
47
+ })
48
+ .then((output) => {
49
+ const info = Array.isArray(output) ? output : [output];
50
+ info.forEach((file) => logger.log(file.path));
46
51
  })
47
- .then((output) => output.map((file) => logger.log(file.path)))
48
52
  .catch((err) => {
49
53
  if (err instanceof Error) {
50
- logger.error(err.message)
51
- logger.error()
52
- logger.error('Specify --help for available options')
53
- process.exitCode = 1
54
+ logger.error(err.message);
55
+ logger.error();
56
+ logger.error("Specify --help for available options");
57
+ process.exitCode = 1;
54
58
  } else {
55
- logger.log(err)
59
+ logger.log(err);
56
60
  }
57
- })
58
- }
61
+ });
62
+ };
package/lib/queue.js CHANGED
@@ -22,23 +22,24 @@
22
22
  */
23
23
 
24
24
  // Strict mode.
25
- 'use strict'
25
+ "use strict";
26
26
 
27
27
  // Configure.
28
- const queue = []
28
+ const queue = [];
29
29
 
30
30
  // Extend object.
31
31
  Object.defineProperties(queue, {
32
32
  // Add drain handler.
33
33
  drain: {
34
- value: (initialValue) => queue.reduce((acc, [, cb]) => cb(acc), initialValue)
34
+ value: (initialValue) =>
35
+ queue.reduce((acc, [, cb]) => cb(acc), initialValue),
35
36
  },
36
37
 
37
38
  // Add pipeline getter.
38
39
  pipeline: {
39
- get: () => queue.map(([value]) => value)
40
- }
41
- })
40
+ get: () => queue.map(([value]) => value),
41
+ },
42
+ });
42
43
 
43
44
  // Exports.
44
- module.exports = queue
45
+ module.exports = queue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depup/sharp-cli",
3
- "version": "5.2.0-depup.0",
3
+ "version": "5.3.0-depup.0",
4
4
  "description": "CLI for sharp. (with updated dependencies)",
5
5
  "keywords": [
6
6
  "sharp-cli",
@@ -27,26 +27,25 @@
27
27
  },
28
28
  "main": "lib/",
29
29
  "scripts": {
30
- "pretest": "standard | snazzy",
30
+ "format": "prettier . --write",
31
+ "pretest": "prettier . --check",
31
32
  "test": "nyc mocha",
32
33
  "posttest": "nyc report --reporter=lcov"
33
34
  },
34
35
  "dependencies": {
35
- "bubble-stream-error": "1.0.x",
36
36
  "glob": "^13.0.6",
37
37
  "is-directory": "^0.3.1",
38
38
  "lodash.pick": "^4.4.0",
39
- "sharp": "^0.34.5",
40
- "yargs": "^18.0.0"
39
+ "sharp": "^0.35.3",
40
+ "yargs": "^18.1.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "fs-extra": "11.3.x",
44
44
  "mocha": "10.8.x",
45
45
  "must": "0.13.x",
46
46
  "nyc": "17.1.x",
47
+ "prettier": "3.9.6",
47
48
  "sinon": "21.0.x",
48
- "snazzy": "9.0.x",
49
- "standard": "17.1.x",
50
49
  "tempy": "1.0.x"
51
50
  },
52
51
  "engines": {
@@ -55,7 +54,7 @@
55
54
  "depup": {
56
55
  "changes": {
57
56
  "glob": {
58
- "from": "11.0.x",
57
+ "from": "10.5.x",
59
58
  "to": "^13.0.6"
60
59
  },
61
60
  "is-directory": {
@@ -67,18 +66,18 @@
67
66
  "to": "^4.4.0"
68
67
  },
69
68
  "sharp": {
70
- "from": "0.34.2",
71
- "to": "^0.34.5"
69
+ "from": "0.34.5",
70
+ "to": "^0.35.3"
72
71
  },
73
72
  "yargs": {
74
73
  "from": "^17.6.2",
75
- "to": "^18.0.0"
74
+ "to": "^18.1.0"
76
75
  }
77
76
  },
78
77
  "depsUpdated": 5,
79
78
  "originalPackage": "sharp-cli",
80
- "originalVersion": "5.2.0",
81
- "processedAt": "2026-03-19T03:28:48.584Z",
79
+ "originalVersion": "5.3.0",
80
+ "processedAt": "2026-08-16T00:30:13.494Z",
82
81
  "smokeTest": "failed"
83
82
  }
84
83
  }