@depup/sharp-cli 5.2.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 (46) hide show
  1. package/.gitattributes +1 -0
  2. package/CHANGELOG.md +336 -0
  3. package/LICENSE.txt +20 -0
  4. package/README.md +35 -0
  5. package/bin/cli.js +32 -0
  6. package/changes.json +26 -0
  7. package/cmd/channel-manipulation/bandbool.js +61 -0
  8. package/cmd/channel-manipulation/ensure-alpha.js +62 -0
  9. package/cmd/channel-manipulation/extract-channel.js +61 -0
  10. package/cmd/channel-manipulation/join-channel.js +60 -0
  11. package/cmd/channel-manipulation/remove-alpha.js +49 -0
  12. package/cmd/colour-manipulation/greyscale.js +50 -0
  13. package/cmd/colour-manipulation/pipeline-colourspace.js +63 -0
  14. package/cmd/colour-manipulation/tint.js +58 -0
  15. package/cmd/colour-manipulation/tocolourspace.js +63 -0
  16. package/cmd/compositing/composite.js +187 -0
  17. package/cmd/operations/affine.js +110 -0
  18. package/cmd/operations/blur.js +87 -0
  19. package/cmd/operations/boolean.js +66 -0
  20. package/cmd/operations/clahe.js +82 -0
  21. package/cmd/operations/convolve.js +103 -0
  22. package/cmd/operations/flatten.js +63 -0
  23. package/cmd/operations/flip.js +49 -0
  24. package/cmd/operations/flop.js +49 -0
  25. package/cmd/operations/gamma.js +66 -0
  26. package/cmd/operations/linear.js +73 -0
  27. package/cmd/operations/median.js +62 -0
  28. package/cmd/operations/modulate.js +78 -0
  29. package/cmd/operations/negate.js +60 -0
  30. package/cmd/operations/normalise.js +69 -0
  31. package/cmd/operations/recomb.js +74 -0
  32. package/cmd/operations/rotate.js +72 -0
  33. package/cmd/operations/sharpen.js +109 -0
  34. package/cmd/operations/threshold.js +73 -0
  35. package/cmd/operations/unflatten.js +49 -0
  36. package/cmd/output.js +125 -0
  37. package/cmd/resizing/extend.js +102 -0
  38. package/cmd/resizing/extract.js +79 -0
  39. package/cmd/resizing/resize.js +124 -0
  40. package/cmd/resizing/trim.js +82 -0
  41. package/lib/cli.js +800 -0
  42. package/lib/constants.js +55 -0
  43. package/lib/convert.js +121 -0
  44. package/lib/index.js +58 -0
  45. package/lib/queue.js +44 -0
  46. package/package.json +84 -0
@@ -0,0 +1,55 @@
1
+ /*!
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2019 Mark van Seventer
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ * the Software, and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ // Strict mode.
25
+ 'use strict'
26
+
27
+ // Package modules.
28
+ const sharp = require('sharp')
29
+
30
+ // Exports.
31
+ module.exports = {
32
+ BLEND: Object.keys(sharp.blend),
33
+ BOOL: Object.keys(sharp.bool),
34
+ CHANNEL: ['red', 'green', 'blue', 'alpha'],
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'],
40
+ FIT: Object.keys(sharp.fit),
41
+ FORMAT: ['avif', 'gif', 'heif', 'jpeg', 'jpg', 'png', 'raw', 'tiff', 'webp'],
42
+ GRAVITY: Object.keys(sharp.gravity),
43
+ HEIF_COMPRESSION: ['hevc', 'av1'],
44
+ INTERPOLATORS: Object.keys(sharp.interpolators),
45
+ KERNEL: Object.keys(sharp.kernel),
46
+ LAYOUT: ['dz', 'google', 'iiif', 'zoomify'],
47
+ POSITION: Object.keys(sharp.position),
48
+ PRESETS: ['default', 'photo', 'picture', 'drawing', 'icon', 'text'],
49
+ RESOLUTION_UNIT: ['cm', 'inch'],
50
+ STRATEGY: Object.keys(sharp.strategy),
51
+ TIFF_COMPRESSION: [
52
+ 'ccittfax4', 'deflate', 'jpeg', 'jp2k', 'lzw', 'none', 'packbits', 'webp', 'zstd'
53
+ ],
54
+ TIFF_PREDICTOR: ['float', 'horizontal', 'none']
55
+ }
package/lib/convert.js ADDED
@@ -0,0 +1,121 @@
1
+ /*!
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2019 Mark van Seventer
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ * the Software, and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ // Strict mode.
25
+ 'use strict'
26
+
27
+ // Standard lib.
28
+ const fs = require('fs')
29
+ const path = require('path')
30
+
31
+ // 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')
36
+
37
+ // Local modules.
38
+ const queue = require('./queue')
39
+
40
+ // Configure.
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
+ }
51
+
52
+ // Exports.
53
+ module.exports = {
54
+ // Convert a list of files.
55
+ files: (input, output, options) => {
56
+ // Resolve files.
57
+ const files = input.reduce((list, input) => {
58
+ return list.concat(globSync(input, { absolute: true }))
59
+ }, [])
60
+
61
+ if (files.length === 0) {
62
+ return Promise.reject(new Error('No input files'))
63
+ }
64
+
65
+ // Process files.
66
+ const isBatch = files.length > 1
67
+ const promises = files.map((src) => {
68
+ // Create pipeline.
69
+ const transformer = queue.drain(sharp(options))
70
+
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
76
+ while ((match = regex.exec(output)) !== null) {
77
+ const [search, prop] = match
78
+ dest = dest.replace(search, parts[prop])
79
+ }
80
+ dest = path.resolve(dest)
81
+
82
+ // If output was not a template, assume dest is a directory when using
83
+ // batch processing.
84
+ const outputAssumeDir = dest === path.resolve(output) && isBatch
85
+ if (outputAssumeDir || isDirectory.sync(dest)) {
86
+ const defaultExt = path.extname(src)
87
+ const desiredExt = transformer.options.formatOut
88
+ dest = path.format({
89
+ dir: dest,
90
+ name: path.basename(src, defaultExt),
91
+ ext: desiredExt in EXTENSIONS ? EXTENSIONS[desiredExt] : defaultExt
92
+ })
93
+ }
94
+
95
+ // Write, attach info and return.
96
+ fs.createReadStream(src).pipe(transformer)
97
+ return transformer
98
+ .toFile(dest)
99
+ .then((info) => Object.assign(info, { src, path: dest }))
100
+ })
101
+ return Promise.all(promises)
102
+ },
103
+
104
+ // Convert a stream.
105
+ stream: (inStream, outStream, options) => {
106
+ return new Promise((resolve, reject) => {
107
+ // Create pipeline.
108
+ const transformer = queue.drain(sharp(options))
109
+
110
+ // Gather return value.
111
+ const info = { }
112
+ transformer.on('info', (_info) => Object.assign(info, _info))
113
+
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
+ }
package/lib/index.js ADDED
@@ -0,0 +1,58 @@
1
+ /*!
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2019 Mark van Seventer
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ * the Software, and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ // Strict mode.
25
+ 'use strict'
26
+
27
+ // Package modules.
28
+ const pick = require('lodash.pick')
29
+
30
+ // Local modules.
31
+ const cli = require('./cli')
32
+ const convert = require('./convert')
33
+
34
+ // Exports.
35
+ module.exports = (args, options = { }) => {
36
+ const logger = options.logger || console // Cast.
37
+
38
+ // Parse arguments and handle i/o.
39
+ return cli.parse(args)
40
+ .then(argv => {
41
+ const options = pick(argv, cli.inputOptions)
42
+ if (argv.input) {
43
+ return convert.files(argv.input, argv.output, options)
44
+ }
45
+ return convert.stream(process.stdin, process.stdout, options)
46
+ })
47
+ .then((output) => output.map((file) => logger.log(file.path)))
48
+ .catch((err) => {
49
+ 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
+ } else {
55
+ logger.log(err)
56
+ }
57
+ })
58
+ }
package/lib/queue.js ADDED
@@ -0,0 +1,44 @@
1
+ /*!
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2019 Mark van Seventer
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ * the Software, and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ // Strict mode.
25
+ 'use strict'
26
+
27
+ // Configure.
28
+ const queue = []
29
+
30
+ // Extend object.
31
+ Object.defineProperties(queue, {
32
+ // Add drain handler.
33
+ drain: {
34
+ value: (initialValue) => queue.reduce((acc, [, cb]) => cb(acc), initialValue)
35
+ },
36
+
37
+ // Add pipeline getter.
38
+ pipeline: {
39
+ get: () => queue.map(([value]) => value)
40
+ }
41
+ })
42
+
43
+ // Exports.
44
+ module.exports = queue
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@depup/sharp-cli",
3
+ "version": "5.2.0-depup.0",
4
+ "description": "CLI for sharp. (with updated dependencies)",
5
+ "keywords": [
6
+ "sharp-cli",
7
+ "depup",
8
+ "updated-dependencies",
9
+ "security",
10
+ "latest",
11
+ "patched",
12
+ "cli",
13
+ "jpeg",
14
+ "libvips",
15
+ "png",
16
+ "sharp",
17
+ "vips",
18
+ "webp"
19
+ ],
20
+ "homepage": "https://github.com/vseventer/sharp-cli",
21
+ "bugs": "https://github.com/vseventer/sharp-cli/issues",
22
+ "license": "MIT",
23
+ "author": "Mark van Seventer <mark@vseventer.com>",
24
+ "repository": "vseventer/sharp-cli",
25
+ "bin": {
26
+ "sharp": "bin/cli.js"
27
+ },
28
+ "main": "lib/",
29
+ "scripts": {
30
+ "pretest": "standard | snazzy",
31
+ "test": "nyc mocha",
32
+ "posttest": "nyc report --reporter=lcov"
33
+ },
34
+ "dependencies": {
35
+ "bubble-stream-error": "1.0.x",
36
+ "glob": "^13.0.6",
37
+ "is-directory": "^0.3.1",
38
+ "lodash.pick": "^4.4.0",
39
+ "sharp": "^0.34.5",
40
+ "yargs": "^18.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "fs-extra": "11.3.x",
44
+ "mocha": "10.8.x",
45
+ "must": "0.13.x",
46
+ "nyc": "17.1.x",
47
+ "sinon": "21.0.x",
48
+ "snazzy": "9.0.x",
49
+ "standard": "17.1.x",
50
+ "tempy": "1.0.x"
51
+ },
52
+ "engines": {
53
+ "node": ">=18.17"
54
+ },
55
+ "depup": {
56
+ "changes": {
57
+ "glob": {
58
+ "from": "11.0.x",
59
+ "to": "^13.0.6"
60
+ },
61
+ "is-directory": {
62
+ "from": "0.3.x",
63
+ "to": "^0.3.1"
64
+ },
65
+ "lodash.pick": {
66
+ "from": "3.1.0",
67
+ "to": "^4.4.0"
68
+ },
69
+ "sharp": {
70
+ "from": "0.34.2",
71
+ "to": "^0.34.5"
72
+ },
73
+ "yargs": {
74
+ "from": "^17.6.2",
75
+ "to": "^18.0.0"
76
+ }
77
+ },
78
+ "depsUpdated": 5,
79
+ "originalPackage": "sharp-cli",
80
+ "originalVersion": "5.2.0",
81
+ "processedAt": "2026-03-19T03:28:48.584Z",
82
+ "smokeTest": "failed"
83
+ }
84
+ }