@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,62 @@
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
+ // @see https://sharp.pixelplumbing.com/api-operation#median
25
+
26
+ // Strict mode.
27
+ 'use strict'
28
+
29
+ // Local modules.
30
+ const queue = require('../../lib/queue')
31
+
32
+ // Configure.
33
+ const positionals = {
34
+ size: {
35
+ desc: 'Square mask size',
36
+ defaultDescription: 3,
37
+ type: 'number'
38
+ }
39
+ }
40
+
41
+ // Command builder.
42
+ const builder = (yargs) => {
43
+ return yargs
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
+ }
50
+
51
+ // Command handler.
52
+ const handler = (args) => {
53
+ return queue.push(['median', (sharp) => sharp.median(args.size)])
54
+ }
55
+
56
+ // Exports.
57
+ module.exports = {
58
+ command: 'median [size]',
59
+ describe: 'Apply median filter',
60
+ builder,
61
+ handler
62
+ }
@@ -0,0 +1,78 @@
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
+ // @see http://sharp.pixelplumbing.com/api-operation#modulate
25
+
26
+ // Strict mode.
27
+ 'use strict'
28
+
29
+ // Package modules.
30
+ const pick = require('lodash.pick')
31
+
32
+ // Local modules.
33
+ const queue = require('../../lib/queue')
34
+
35
+ // Configure.
36
+ const options = {
37
+ brightness: {
38
+ desc: 'Brightness multiplier',
39
+ type: 'number'
40
+ },
41
+ hue: {
42
+ desc: 'Degrees for hue rotation',
43
+ type: 'number'
44
+ },
45
+ lightness: {
46
+ desc: 'Lightness addend',
47
+ type: 'number'
48
+ },
49
+ saturation: {
50
+ desc: 'Saturation multiplier',
51
+ type: 'number'
52
+ }
53
+ }
54
+ const optionNames = Object.keys(options)
55
+
56
+ // Command builder.
57
+ const builder = (yargs) => {
58
+ return yargs
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')
65
+ .options(options)
66
+ .group(optionNames, 'Command Options')
67
+ }
68
+
69
+ // Command handler.
70
+ const handler = (args) => queue.push(['modulate', (sharp) => sharp.modulate(pick(args, optionNames))])
71
+
72
+ // Exports.
73
+ module.exports = {
74
+ command: 'modulate',
75
+ describe: 'Transforms the image using brightness, saturation, hue rotation, and lightness',
76
+ builder,
77
+ handler
78
+ }
@@ -0,0 +1,60 @@
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
+ // @see https://sharp.pixelplumbing.com/api-operation#negate
25
+
26
+ // Strict mode.
27
+ 'use strict'
28
+
29
+ // Local modules.
30
+ const queue = require('../../lib/queue')
31
+
32
+ // Configure.
33
+ const options = {
34
+ alpha: {
35
+ desc: 'Whether or not to negate any alpha channel',
36
+ type: 'boolean'
37
+ }
38
+ }
39
+
40
+ // Command builder.
41
+ const builder = (yargs) => {
42
+ const optionNames = Object.keys(options)
43
+ return yargs
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')
47
+ .options(options)
48
+ .group(optionNames, 'Command Options')
49
+ }
50
+
51
+ // Command handler.
52
+ const handler = (args) => queue.push(['negate', (sharp) => sharp.negate(args.alpha)])
53
+
54
+ // Exports.
55
+ module.exports = {
56
+ command: 'negate',
57
+ describe: 'Produce the "negative" of the image',
58
+ builder,
59
+ handler
60
+ }
@@ -0,0 +1,69 @@
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
+ // @see https://sharp.pixelplumbing.com/api-operation#normalise
25
+
26
+ // Strict mode.
27
+ 'use strict'
28
+
29
+ // Package modules.
30
+ const pick = require('lodash.pick')
31
+
32
+ // Local modules.
33
+ const queue = require('../../lib/queue')
34
+
35
+ const options = {
36
+ lower: {
37
+ default: 1,
38
+ desc: 'Percentile below which luminance values will be underexposed',
39
+ type: 'number'
40
+ },
41
+ upper: {
42
+ default: 99,
43
+ desc: 'Percentile below which luminance values will be overexposed',
44
+ type: 'number'
45
+ }
46
+ }
47
+ const optionNames = Object.keys(options)
48
+
49
+ // Command builder.
50
+ const builder = (yargs) => {
51
+ return yargs
52
+ .strict()
53
+ .epilog('For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#normalise')
54
+ .example('$0 normalise')
55
+ .options(options)
56
+ .group(optionNames, 'Command Options')
57
+ }
58
+
59
+ // Command handler.
60
+ const handler = (args) => queue.push(['normalise', (sharp) => sharp.normalise(pick(args, optionNames))])
61
+
62
+ // Exports.
63
+ module.exports = {
64
+ command: 'normalise',
65
+ aliases: 'normalize',
66
+ describe: 'Enhance output image contrast by stretching its luminance to cover the full dynamic range',
67
+ builder,
68
+ handler
69
+ }
@@ -0,0 +1,74 @@
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
+ // @see https://sharp.dimens.io/api-operation#recomb
25
+
26
+ // Strict mode.
27
+ 'use strict'
28
+
29
+ // Local modules.
30
+ const queue = require('../../lib/queue')
31
+
32
+ // Configure.
33
+ const placeholders = {
34
+ matrix: {
35
+ desc: 'Recombination matrix',
36
+ nargs: 3 * 3,
37
+ type: 'number'
38
+ }
39
+ }
40
+
41
+ // Command builder.
42
+ const builder = (yargs) => {
43
+ return yargs
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 => {
48
+ if (!(Array.isArray(argv.matrix) && argv.matrix.length === 9)) {
49
+ throw new Error('Expected matrix positional to have 9 values')
50
+ }
51
+ return true
52
+ })
53
+ .positional('matrix', placeholders.matrix)
54
+ }
55
+
56
+ // Command handler.
57
+ 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
+ }
67
+
68
+ // Exports.
69
+ module.exports = {
70
+ command: 'recomb <matrix..>',
71
+ describe: 'Recomb the image with the specified matrix',
72
+ builder,
73
+ handler
74
+ }
@@ -0,0 +1,72 @@
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
+ // @see https://sharp.pixelplumbing.com/api-operation#rotate
25
+
26
+ // Strict mode.
27
+ 'use strict'
28
+
29
+ // Local modules.
30
+ const queue = require('../../lib/queue')
31
+
32
+ // Configure.
33
+ const positionals = {
34
+ angle: {
35
+ defaultDescription: 'auto',
36
+ desc: 'Angle of rotation',
37
+ type: 'number'
38
+ }
39
+ }
40
+
41
+ const options = {
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
+ }
48
+
49
+ // Command builder.
50
+ const builder = (yargs) => {
51
+ const optionNames = Object.keys(options)
52
+ return yargs
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)
57
+ .options(options)
58
+ .group(optionNames, 'Command Options')
59
+ }
60
+
61
+ // Command handler.
62
+ const handler = (args) => {
63
+ return queue.push(['rotate', (sharp) => sharp.rotate(args.angle, { background: args.background })])
64
+ }
65
+
66
+ // Exports.
67
+ module.exports = {
68
+ command: 'rotate [angle]',
69
+ describe: 'Rotate the output image',
70
+ builder,
71
+ handler
72
+ }
@@ -0,0 +1,109 @@
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
+ // @see https://sharp.pixelplumbing.com/api-operation#sharpen
25
+
26
+ // Strict mode.
27
+ 'use strict'
28
+
29
+ // Package modules.
30
+ const pick = require('lodash.pick')
31
+
32
+ // Local modules.
33
+ const queue = require('../../lib/queue')
34
+
35
+ // Configure.
36
+ const positionals = {
37
+ sigma: {
38
+ desc: 'The sigma of the Gaussian mask',
39
+ defaultDescription: '1 + radius / 2',
40
+ type: 'number'
41
+ }
42
+ }
43
+
44
+ const options = {
45
+ m1: {
46
+ alias: 'flat',
47
+ desc: 'The level of sharpening to apply to "flat" areas',
48
+ defaultDescription: 1.0,
49
+ type: 'number'
50
+ },
51
+ m2: {
52
+ alias: 'jagged',
53
+ desc: 'The level of sharpening to apply to "jagged" areas',
54
+ defaultDescription: 2.0,
55
+ type: 'number'
56
+ },
57
+ x1: {
58
+ desc: 'The threshold between "flat" and "jagged" areas',
59
+ defaultDescription: 2.0,
60
+ type: 'number'
61
+ },
62
+ y2: {
63
+ desc: 'The maximum amount of brightening',
64
+ defaultDescription: 10.0,
65
+ type: 'number'
66
+ },
67
+ y3: {
68
+ desc: 'The maximum amount of darkening',
69
+ defaultDescription: 20.0,
70
+ type: 'number'
71
+ }
72
+ }
73
+ const optionNames = Object.keys(options)
74
+
75
+ // Command builder.
76
+ const builder = (yargs) => {
77
+ return yargs
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)
84
+ .options(options)
85
+ .group(optionNames, 'Command Options')
86
+ }
87
+
88
+ // Command handler.
89
+ const handler = (args) => {
90
+ const options = {
91
+ ...pick(args, Object.keys(positionals)),
92
+ ...pick(args, optionNames)
93
+ }
94
+
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
+ }
102
+
103
+ // Exports.
104
+ module.exports = {
105
+ command: 'sharpen [sigma]',
106
+ describe: 'Sharpen the image',
107
+ builder,
108
+ handler
109
+ }
@@ -0,0 +1,73 @@
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
+ // @see https://sharp.pixelplumbing.com/api-operation#threshold
25
+
26
+ // Strict mode.
27
+ 'use strict'
28
+
29
+ // Local modules.
30
+ const queue = require('../../lib/queue')
31
+
32
+ // Configure.
33
+ const positionals = {
34
+ value: {
35
+ desc: 'A value in the range 0-255 representing the level at which the threshold will be applied',
36
+ defaultDescription: 128,
37
+ type: 'number'
38
+ }
39
+ }
40
+
41
+ const options = {
42
+ greyscale: {
43
+ alias: 'grayscale',
44
+ desc: 'Convert to single channel greyscale',
45
+ type: 'boolean'
46
+ }
47
+ }
48
+
49
+ // Command builder.
50
+ const builder = (yargs) => {
51
+ const optionNames = Object.keys(options)
52
+ return yargs
53
+ .strict()
54
+ .epilog('For more information on available options, please visit https://sharp.pixelplumbing.com/api-operation#threshold')
55
+ .positional('value', positionals.value)
56
+ .options(options)
57
+ .group(optionNames, 'Command Options')
58
+ }
59
+
60
+ // Command handler.
61
+ const handler = (args) => {
62
+ return queue.push(['threshold', (sharp) => {
63
+ return sharp.threshold(args.value, { greyscale: args.greyscale })
64
+ }])
65
+ }
66
+
67
+ // Exports.
68
+ module.exports = {
69
+ command: 'threshold [value]',
70
+ describe: 'Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0',
71
+ builder,
72
+ handler
73
+ }
@@ -0,0 +1,49 @@
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
+ // @see https://sharp.dimens.io/api-operation#unflatten
25
+
26
+ // Strict mode.
27
+ 'use strict'
28
+
29
+ // Local modules.
30
+ const queue = require('../../lib/queue')
31
+
32
+ // Command builder.
33
+ const builder = (yargs) => {
34
+ return yargs
35
+ .strict()
36
+ .example('$0 unflatten')
37
+ .epilog('For more information on available options, please visit https://sharp.dimens.io/api-operation#unflatten')
38
+ }
39
+
40
+ // Command handler.
41
+ const handler = (args) => queue.push(['unflatten', (sharp) => sharp.unflatten()])
42
+
43
+ // Exports.
44
+ module.exports = {
45
+ command: 'unflatten',
46
+ describe: 'Ensure the image has an alpha channel with all white pixel values made fully transparent',
47
+ builder,
48
+ handler
49
+ }