@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/cli.js CHANGED
@@ -22,191 +22,205 @@
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')
29
- const sharp = require('sharp')
30
- const yargs = require('yargs')
28
+ const pick = require("lodash.pick");
29
+ const sharp = require("sharp");
30
+ const yargs = require("yargs");
31
31
 
32
32
  // Local modules.
33
- const constants = require('./constants')
34
- const pkg = require('../package.json')
35
- const queue = require('./queue')
33
+ const constants = require("./constants");
34
+ const pkg = require("../package.json");
35
+ const queue = require("./queue");
36
36
 
37
37
  // Configure.
38
- const IS_TEXT_TERMINAL = process.stdin.isTTY
38
+ const IS_TEXT_TERMINAL = process.stdin.isTTY;
39
39
 
40
40
  // Options.
41
- const global = 'Global Options'
42
- const input = 'Input Options'
43
- const optimize = 'Optimization Options'
44
- const output = 'Output Options'
41
+ const global = "Global Options";
42
+ const input = "Input Options";
43
+ const optimize = "Optimization Options";
44
+ const output = "Output Options";
45
45
 
46
46
  const globalOptions = {
47
47
  // @see https://sharp.pixelplumbing.com/api-constructor/
48
48
  input: {
49
- alias: 'i',
50
- defaultDescription: 'stdin',
49
+ alias: "i",
50
+ defaultDescription: "stdin",
51
51
  demand: IS_TEXT_TERMINAL,
52
- desc: 'Path to (an) image file(s)',
52
+ desc: "Path to (an) image file(s)",
53
53
  group: global,
54
- implies: 'output',
55
- type: 'array'
54
+ implies: "output",
55
+ type: "array",
56
56
  },
57
57
 
58
58
  // @see https://sharp.pixelplumbing.com/api-output/
59
59
  output: {
60
- alias: 'o',
61
- defaultDescription: 'stdout',
60
+ alias: "o",
61
+ defaultDescription: "stdout",
62
62
  demand: IS_TEXT_TERMINAL,
63
- desc: 'Directory or URI template to write the image files to',
63
+ desc: "Directory or URI template to write the image files to",
64
64
  group: global,
65
- type: 'string'
65
+ type: "string",
66
66
  },
67
67
 
68
68
  // @see https://sharp.pixelplumbing.com/api-output#timeout
69
69
  timeout: {
70
- desc: 'Number of seconds after which processing will be stopped',
70
+ desc: "Number of seconds after which processing will be stopped",
71
71
  group: global,
72
- type: 'number'
73
- }
74
- }
72
+ type: "number",
73
+ },
74
+ };
75
75
 
76
76
  // @see https://sharp.pixelplumbing.com/api-constructor
77
77
  const inputOptions = {
78
78
  animated: {
79
- desc: 'Read all frames/pages of an animated image',
79
+ desc: "Read all frames/pages of an animated image",
80
80
  group: input,
81
- type: 'boolean'
81
+ type: "boolean",
82
82
  },
83
83
  autoOrient: {
84
- desc: 'Rotate/flip the image to match EXIF Orientation, if any',
84
+ desc: "Rotate/flip the image to match EXIF Orientation, if any",
85
85
  group: input,
86
- type: 'boolean'
86
+ type: "boolean",
87
87
  },
88
88
  failOn: {
89
89
  choices: constants.FAIL_ON,
90
- defaultDescription: 'warning',
91
- desc: 'Level of sensitivity to invalid images',
92
- group: input
90
+ defaultDescription: "warning",
91
+ desc: "Level of sensitivity to invalid images",
92
+ group: input,
93
93
  },
94
94
  density: {
95
- desc: 'DPI for vector images',
95
+ desc: "DPI for vector images",
96
96
  defaultDescription: 72,
97
97
  group: input,
98
- type: 'number'
98
+ type: "number",
99
99
  },
100
100
  ignoreIcc: {
101
101
  default: false,
102
- desc: 'Should the embedded ICC profile, if any, be ignored',
102
+ desc: "Should the embedded ICC profile, if any, be ignored",
103
103
  group: input,
104
- type: 'boolean'
104
+ type: "boolean",
105
105
  },
106
106
  level: {
107
- desc: 'Level to extract from a multi-level input (OpenSlide), zero based',
107
+ desc: "Level to extract from a multi-level input (OpenSlide), zero based",
108
108
  defaultDescription: 0,
109
109
  group: input,
110
- type: 'number'
110
+ type: "number",
111
111
  },
112
112
  limitInputPixels: {
113
- defaultDescription: 0x3FFF * 0x3FFF,
114
- desc: 'Do not process input images where the number of pixels (width x height) exceeds this limit',
113
+ defaultDescription: 0x3fff * 0x3fff,
114
+ desc: "Do not process input images where the number of pixels (width x height) exceeds this limit",
115
115
  group: input,
116
- type: 'number'
116
+ type: "number",
117
117
  },
118
118
  page: {
119
119
  defaultDescription: 0,
120
- desc: 'Page number to start extracting from for multi-page input',
120
+ desc: "Page number to start extracting from for multi-page input",
121
121
  group: input,
122
- type: 'number'
122
+ type: "number",
123
123
  },
124
124
  pages: {
125
125
  defaultDescription: 1,
126
- desc: 'Number of pages to extract for multi-page input',
126
+ desc: "Number of pages to extract for multi-page input",
127
127
  group: input,
128
- type: 'number'
128
+ type: "number",
129
129
  },
130
130
  pdfBackground: {
131
- desc: 'Background colour to use when PDF is partially transparent',
131
+ desc: "Background colour to use when PDF is partially transparent",
132
132
  group: input,
133
- type: 'string'
133
+ type: "string",
134
134
  },
135
135
  sequentialRead: {
136
136
  default: false,
137
- desc: 'Use sequential rather than random access where possible',
137
+ desc: "Use sequential rather than random access where possible",
138
138
  group: input,
139
- type: 'boolean'
139
+ type: "boolean",
140
140
  },
141
141
  subifd: {
142
142
  defaultDescription: -1,
143
- desc: 'subIFD to extract for OME-TIFF',
143
+ desc: "subIFD to extract for OME-TIFF",
144
144
  group: input,
145
- type: 'number'
145
+ type: "number",
146
146
  },
147
147
  unlimited: {
148
- desc: 'Remove safety features that help prevent memory exhaustion',
148
+ desc: "Remove safety features that help prevent memory exhaustion",
149
149
  group: input,
150
- type: 'boolean'
151
- }
152
- }
150
+ type: "boolean",
151
+ },
152
+ };
153
153
 
154
154
  const outputOptions = {
155
+ // @see https://sharp.pixelplumbing.com/api-output#tiff
156
+ bigtiff: {
157
+ desc: "Use BigTIFF variant",
158
+ group: output,
159
+ type: "boolean",
160
+ },
161
+
155
162
  // @see https://sharp.pixelplumbing.com/api-output#png
156
163
  compressionLevel: {
157
- alias: 'c',
158
- desc: 'zlib compression level',
164
+ alias: "c",
165
+ desc: "zlib compression level",
159
166
  defaultDescription: 6,
160
167
  group: output,
161
- type: 'number'
168
+ type: "number",
162
169
  },
163
170
 
164
171
  // @see https://sharp.pixelplumbing.com/api-output#toformat
165
172
  format: {
166
- alias: 'f',
173
+ alias: "f",
167
174
  choices: constants.FORMAT,
168
- defaultDescription: 'input',
169
- desc: 'Force output to a given format',
170
- group: output
175
+ defaultDescription: "input",
176
+ desc: "Force output to a given format",
177
+ group: output,
178
+ },
179
+
180
+ // @see https://sharp.pixelplumbing.com/api-output#gif
181
+ keepDuplicateFrames: {
182
+ desc: "Keep duplicate frames in the output instead of combining them",
183
+ group: output,
184
+ type: "boolean",
171
185
  },
172
186
 
173
187
  // @see https://sharp.pixelplumbing.com/api-output#withmetadata
174
188
  metadata: {
175
- alias: ['m', 'withMetadata'],
176
- desc: 'Include all metadata (EXIF, XMP, IPTC) from the input image in the output image',
189
+ alias: ["m", "withMetadata"],
190
+ desc: "Include all metadata (EXIF, XMP, IPTC) from the input image in the output image",
177
191
  group: output,
178
- type: 'boolean'
192
+ type: "boolean",
179
193
  },
180
- 'metadata.density': {
181
- desc: 'Number of pixels per inch (DPI)',
194
+ "metadata.density": {
195
+ desc: "Number of pixels per inch (DPI)",
182
196
  group: output,
183
- type: 'number'
197
+ type: "number",
184
198
  },
185
- 'metadata.exif': {
186
- defaultDescription: '{}',
187
- desc: 'Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data',
199
+ "metadata.exif": {
200
+ defaultDescription: "{}",
201
+ desc: "Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data",
188
202
  group: output,
189
- type: 'object'
203
+ type: "object",
190
204
  },
191
- 'metadata.icc': {
192
- defaultDescription: 'sRGB',
193
- desc: 'Filesystem path to output ICC profile',
205
+ "metadata.icc": {
206
+ defaultDescription: "sRGB",
207
+ desc: "Filesystem path to output ICC profile",
194
208
  group: output,
195
- type: 'string'
209
+ type: "string",
196
210
  },
197
- 'metadata.orientation': {
198
- desc: 'Used to update the EXIF Orientation tag',
211
+ "metadata.orientation": {
212
+ desc: "Used to update the EXIF Orientation tag",
199
213
  group: output,
200
- type: 'number'
214
+ type: "number",
201
215
  },
202
216
 
203
217
  // @see https://sharp.pixelplumbing.com/api-output#jpeg
204
218
  // @see https://sharp.pixelplumbing.com/api-output#png
205
219
  progressive: {
206
- alias: 'p',
207
- desc: 'Use progressive (interlace) scan',
220
+ alias: "p",
221
+ desc: "Use progressive (interlace) scan",
208
222
  group: output,
209
- type: 'boolean'
223
+ type: "boolean",
210
224
  },
211
225
 
212
226
  // @see https://sharp.pixelplumbing.com/api-output#avif
@@ -214,79 +228,79 @@ const outputOptions = {
214
228
  // @see https://sharp.pixelplumbing.com/api-output#tiff
215
229
  // @see https://sharp.pixelplumbing.com/api-output#webp
216
230
  quality: {
217
- alias: 'q',
218
- desc: 'Quality',
219
- defaultDescription: '80',
231
+ alias: "q",
232
+ desc: "Quality",
233
+ defaultDescription: "80",
220
234
  group: output,
221
- type: 'number'
222
- }
223
- }
235
+ type: "number",
236
+ },
237
+ };
224
238
 
225
239
  const optimizationOptions = {
226
240
  // @see https://sharp.pixelplumbing.com/api-output#png
227
241
  adaptiveFiltering: {
228
- desc: 'Use adaptive row filtering',
242
+ desc: "Use adaptive row filtering",
229
243
  group: optimize,
230
- type: 'boolean'
244
+ type: "boolean",
231
245
  },
232
246
 
233
247
  // @see https://sharp.pixelplumbing.com/api-output#webp
234
248
  alphaQuality: {
235
- desc: 'Quality of alpha layer',
236
- defaultDescription: '80',
249
+ desc: "Quality of alpha layer",
250
+ defaultDescription: "80",
237
251
  group: optimize,
238
- type: 'number'
252
+ type: "number",
239
253
  },
240
254
 
241
255
  // @see https://sharp.pixelplumbing.com/api-output#tiff
242
256
  bitdepth: {
243
257
  choices: [1, 2, 4, 8],
244
258
  defaultDescription: 8,
245
- desc: 'Reduce bitdepth to 1, 2, or 4 bit',
246
- group: optimize
259
+ desc: "Reduce bitdepth to 1, 2, or 4 bit",
260
+ group: optimize,
247
261
  },
248
262
 
249
263
  // @see https://sharp.pixelplumbing.com/api-output#avif
250
264
  // @see https://sharp.pixelplumbing.com/api-output#jpeg
251
265
  chromaSubsampling: {
252
266
  desc: 'Set to "4:4:4" to prevent chroma subsampling when quality <= 90',
253
- defaultDescription: '4:4:4 (AVIF) / 4:2:0',
267
+ defaultDescription: "4:4:4 (AVIF) / 4:2:0",
254
268
  group: optimize,
255
- type: 'string'
269
+ type: "string",
256
270
  },
257
271
 
258
272
  // @see https://sharp.pixelplumbing.com/api-output#gif
259
- // @see https://sharp.dimens.io/api-output#png
273
+ // @see https://sharp.pixelplumbing.com/api-output#png
260
274
  colors: {
261
- alias: 'colours',
275
+ alias: "colours",
262
276
  defaultDescription: 256,
263
- desc: 'Maximum number of palette entries',
277
+ desc: "Maximum number of palette entries",
264
278
  group: optimize,
265
- type: 'number'
279
+ type: "number",
266
280
  },
267
281
 
268
282
  // @see https://sharp.pixelplumbing.com/api-output#tiff
269
283
  compression: {
270
284
  choices: constants.TIFF_COMPRESSION,
271
- default: 'jpeg',
272
- desc: 'Compression options',
273
- group: optimize
285
+ default: "jpeg",
286
+ desc: "Compression options",
287
+ group: optimize,
274
288
  },
275
289
 
276
290
  // @see https://sharp.pixelplumbing.com/api-output#gif
277
291
  delay: {
278
- desc: 'Delay(s) between animation frames',
292
+ desc: "Delay(s) between animation frames",
279
293
  group: optimize,
280
- type: 'number'
294
+ type: "number",
281
295
  },
282
296
 
283
297
  // @see https://sharp.pixelplumbing.com/api-output#gif
284
- // @see https://sharp.dimens.io/api-output#png
298
+ // @see https://sharp.pixelplumbing.com/api-output#png
285
299
  dither: {
286
- desc: 'Level of Floyd-Steinberg error diffusion',
287
- defaultDescription: '1.0',
300
+ desc: "Level of Floyd-Steinberg error diffusion",
301
+ defaultDescription: "1.0",
288
302
  group: optimize,
289
- type: 'number'
303
+ type: "number",
290
304
  },
291
305
 
292
306
  // @see https://sharp.pixelplumbing.com/api-output#avif
@@ -295,326 +309,347 @@ const optimizationOptions = {
295
309
  // @see https://sharp.pixelplumbing.com/api-output#png
296
310
  // @see https://sharp.pixelplumbing.com/api-output#webp
297
311
  effort: {
298
- defaultDescription: '7 (GIF, PNG) / 4',
299
- desc: 'Level of CPU effort to reduce file size',
312
+ defaultDescription: "7 (GIF, PNG) / 4",
313
+ desc: "Level of CPU effort to reduce file size",
300
314
  group: optimize,
301
- type: 'number'
315
+ type: "number",
302
316
  },
303
317
 
304
318
  // @see https://sharp.pixelplumbing.com/api-output#heif
305
319
  hbitdepth: {
306
320
  choices: [8, 10, 12],
307
321
  defaultDescription: 8,
308
- desc: 'Set bitdepth to 8, 10, or 12 bit',
309
- group: optimize
322
+ desc: "Set bitdepth to 8, 10, or 12 bit",
323
+ group: optimize,
310
324
  },
311
325
 
312
326
  // @see https://sharp.pixelplumbing.com/api-output#heif
313
327
  hcompression: {
314
328
  choices: constants.HEIF_COMPRESSION,
315
- default: 'av1',
316
- desc: 'Compression format',
317
- group: optimize
329
+ default: "av1",
330
+ desc: "Compression format",
331
+ group: optimize,
318
332
  },
319
333
 
320
334
  // @see https://sharp.pixelplumbing.com/api-output#gif
321
335
  interFrameMaxError: {
322
- desc: 'Maximum inter-frame error for transparency',
336
+ desc: "Maximum inter-frame error for transparency",
323
337
  group: optimize,
324
- type: 'number'
338
+ type: "number",
325
339
  },
326
340
 
327
341
  // @see https://sharp.pixelplumbing.com/api-output#gif
328
342
  interPaletteMaxError: {
329
- desc: 'Maximum inter-palette error for palette reuse',
343
+ desc: "Maximum inter-palette error for palette reuse",
330
344
  group: optimize,
331
- type: 'number'
345
+ type: "number",
332
346
  },
333
347
 
334
348
  // @see https://sharp.pixelplumbing.com/api-output#gif
335
349
  loop: {
336
350
  default: 0,
337
- desc: 'Number of animation iterations',
351
+ desc: "Number of animation iterations",
338
352
  group: optimize,
339
- type: 'number'
353
+ type: "number",
340
354
  },
341
355
 
342
356
  // @see https://sharp.pixelplumbing.com/api-output#avif
343
357
  // @see https://sharp.pixelplumbing.com/api-output#webp
344
358
  lossless: {
345
- desc: 'Use lossless compression mode',
359
+ desc: "Use lossless compression mode",
346
360
  group: optimize,
347
- type: 'boolean'
361
+ type: "boolean",
348
362
  },
349
363
 
350
364
  // @see https://sharp.pixelplumbing.com/api-output#tiff
351
365
  miniswhite: {
352
- desc: 'Write 1-bit images as miniswhite',
366
+ desc: "Write 1-bit images as miniswhite",
353
367
  group: optimize,
354
- type: 'boolean'
368
+ type: "boolean",
355
369
  },
356
370
 
357
371
  // @see https://sharp.pixelplumbing.com/api-output#webp
358
372
  minSize: {
359
- desc: 'Prevent use of animation key frames to minimize file size',
373
+ desc: "Prevent use of animation key frames to minimize file size",
360
374
  group: optimize,
361
- type: 'boolean'
375
+ type: "boolean",
362
376
  },
363
377
 
364
378
  // @see https://sharp.pixelplumbing.com/api-output#webp
365
379
  mixed: {
366
- desc: 'Allow mixture of lossy and lossless animation frames',
380
+ desc: "Allow mixture of lossy and lossless animation frames",
367
381
  group: optimize,
368
- type: 'boolean'
382
+ type: "boolean",
369
383
  },
370
384
 
371
385
  // @see https://sharp.pixelplumbing.com/api-output#jpeg
372
386
  mozjpeg: {
373
- desc: 'Use mozjpeg defaults',
387
+ desc: "Use mozjpeg defaults",
374
388
  group: optimize,
375
- type: 'boolean'
389
+ type: "boolean",
376
390
  },
377
391
 
378
392
  // @see https://sharp.pixelplumbing.com/api-output#webp
379
393
  nearLossless: {
380
- desc: 'Use near_lossless compression mode',
394
+ desc: "Use near_lossless compression mode",
381
395
  group: optimize,
382
- type: 'boolean'
396
+ type: "boolean",
383
397
  },
384
398
 
385
399
  // @see https://sharp.pixelplumbing.com/api-output#jpeg
386
400
  optimise: {
387
- alias: 'optimize',
388
- desc: 'Apply optimiseScans, overshootDeringing, and trellisQuantisation',
401
+ alias: "optimize",
402
+ desc: "Apply optimiseScans, overshootDeringing, and trellisQuantisation",
389
403
  group: optimize,
390
- type: 'boolean'
404
+ type: "boolean",
391
405
  },
392
406
 
393
407
  // @see https://sharp.pixelplumbing.com/api-output#jpeg
394
408
  optimiseCoding: {
395
- alias: 'optimizeCoding',
409
+ alias: "optimizeCoding",
396
410
  default: true,
397
- desc: 'Optimise Huffman coding tables',
411
+ desc: "Optimise Huffman coding tables",
398
412
  group: optimize,
399
- type: 'boolean'
413
+ type: "boolean",
400
414
  },
401
415
 
402
416
  // @see https://sharp.pixelplumbing.com/api-output#jpeg
403
417
  optimiseScans: {
404
- alias: 'optimizeScans',
405
- desc: 'Optimise progressive scans',
418
+ alias: "optimizeScans",
419
+ desc: "Optimise progressive scans",
406
420
  group: optimize,
407
- implies: 'progressive',
408
- type: 'boolean'
421
+ implies: "progressive",
422
+ type: "boolean",
409
423
  },
410
424
 
411
425
  // @see https://sharp.pixelplumbing.com/api-output#jpeg
412
426
  overshootDeringing: {
413
- desc: 'Apply overshoot deringing',
427
+ desc: "Apply overshoot deringing",
414
428
  group: optimize,
415
- type: 'boolean'
429
+ type: "boolean",
416
430
  },
417
431
 
418
- // @see https://sharp.dimens.io/api-output#png
432
+ // @see https://sharp.pixelplumbing.com/api-output#png
419
433
  palette: {
420
- desc: 'Quantise to a palette-based image with alpha transparency support',
434
+ desc: "Quantise to a palette-based image with alpha transparency support",
421
435
  group: optimize,
422
- type: 'boolean'
436
+ type: "boolean",
423
437
  },
424
438
 
425
439
  // @see https://sharp.pixelplumbing.com/api-output#tiff
426
440
  predictor: {
427
441
  choices: constants.TIFF_PREDICTOR,
428
- default: 'horizontal',
429
- desc: 'Compression predictor',
430
- group: optimize
442
+ default: "horizontal",
443
+ desc: "Compression predictor",
444
+ group: optimize,
431
445
  },
432
446
 
433
447
  // @see https://sharp.pixelplumbing.com/api-output#webp
434
448
  preset: {
435
449
  choices: constants.PRESETS,
436
- default: 'default',
437
- desc: 'Named preset for preprocessing/filtering',
438
- group: optimize
450
+ default: "default",
451
+ desc: "Named preset for preprocessing/filtering",
452
+ group: optimize,
439
453
  },
440
454
 
441
455
  // @see https://sharp.pixelplumbing.com/api-output#tiff
442
456
  pyramid: {
443
- desc: 'Write an image pyramid',
457
+ desc: "Write an image pyramid",
444
458
  group: optimize,
445
- type: 'boolean'
459
+ type: "boolean",
446
460
  },
447
461
 
448
462
  // @see https://sharp.pixelplumbing.com/api-output#jpeg
449
463
  quantisationTable: {
450
- alias: 'quantizationTable',
451
- defaultDescription: '0',
452
- desc: 'Quantization table to use',
464
+ alias: "quantizationTable",
465
+ defaultDescription: "0",
466
+ desc: "Quantization table to use",
453
467
  group: optimize,
454
- type: 'number'
468
+ type: "number",
455
469
  },
456
470
 
457
471
  // @see https://sharp.pixelplumbing.com/api-output#gif
458
472
  reuse: {
459
- alias: ['reoptimise', 'reoptimize'],
460
- desc: 'Always generate new palettes (slow)',
473
+ alias: ["reoptimise", "reoptimize"],
474
+ desc: "Always generate new palettes (slow)",
461
475
  group: optimize,
462
- type: 'boolean'
476
+ type: "boolean",
463
477
  },
464
478
 
465
479
  // @see https://sharp.pixelplumbing.com/api-output
466
480
  resolutionUnit: {
467
481
  choices: constants.RESOLUTION_UNIT,
468
- defaultDescription: 'inch',
469
- desc: 'Resolution unit',
470
- group: optimize
482
+ defaultDescription: "inch",
483
+ desc: "Resolution unit",
484
+ group: optimize,
471
485
  },
472
486
 
473
487
  // @see https://sharp.pixelplumbing.com/api-output#webp
474
488
  smartDeblock: {
475
- desc: 'Auto-adjust the deblocking filter, can improve low contrast edges',
489
+ desc: "Auto-adjust the deblocking filter, can improve low contrast edges",
476
490
  group: optimize,
477
- type: 'boolean'
491
+ type: "boolean",
478
492
  },
479
493
 
480
494
  // @see https://sharp.pixelplumbing.com/api-output#webp
481
495
  smartSubsample: {
482
- desc: 'High quality chroma subsampling',
496
+ desc: "High quality chroma subsampling",
483
497
  group: optimize,
484
- type: 'boolean'
498
+ type: "boolean",
485
499
  },
486
500
 
487
501
  // @see https://sharp.pixelplumbing.com/api-output#tile
488
502
  tileBackground: {
489
- defaultDescription: 'rgba(255, 255, 255, 1)',
490
- desc: 'Background colour, parsed by the color module',
503
+ defaultDescription: "rgba(255, 255, 255, 1)",
504
+ desc: "Background colour, parsed by the color module",
491
505
  group: optimize,
492
- type: 'string'
506
+ type: "string",
493
507
  },
494
508
 
495
509
  // @see https://sharp.pixelplumbing.com/api-output#tiff
496
510
  tileHeight: {
497
- desc: 'Vertical tile size',
511
+ desc: "Vertical tile size",
498
512
  group: optimize,
499
- type: 'number'
513
+ type: "number",
500
514
  },
501
515
 
502
516
  // @see https://sharp.pixelplumbing.com/api-output#tiff
503
517
  tileWidth: {
504
- desc: 'Horizontal tile size',
518
+ desc: "Horizontal tile size",
505
519
  group: optimize,
506
- type: 'number'
520
+ type: "number",
507
521
  },
508
522
 
509
523
  // @see https://sharp.pixelplumbing.com/api-output#jpeg
510
524
  trellisQuantisation: {
511
- desc: 'Apply trellis quantisation',
525
+ desc: "Apply trellis quantisation",
512
526
  group: optimize,
513
- type: 'boolean'
527
+ type: "boolean",
514
528
  },
515
529
 
516
530
  // @see https://sharp.pixelplumbing.com/api-output#tiff
517
531
  xres: {
518
- defaultDescription: '1.0',
519
- desc: 'Horizontal resolution',
532
+ defaultDescription: "1.0",
533
+ desc: "Horizontal resolution",
520
534
  group: optimize,
521
- type: 'number'
535
+ type: "number",
522
536
  },
523
537
 
524
538
  // @see https://sharp.pixelplumbing.com/api-output#tiff
525
539
  yres: {
526
- defaultDescription: '1.0',
527
- desc: 'Vertical resolution',
540
+ defaultDescription: "1.0",
541
+ desc: "Vertical resolution",
528
542
  group: optimize,
529
- type: 'number'
530
- }
531
- }
543
+ type: "number",
544
+ },
545
+ };
532
546
 
533
547
  const options = {
534
548
  ...globalOptions,
535
549
  ...inputOptions,
536
550
  ...outputOptions,
537
- ...optimizationOptions
538
- }
551
+ ...optimizationOptions,
552
+ };
539
553
 
540
554
  // Configure.
541
555
  const cli = yargs
542
- .parserConfiguration({ 'populate--': true })
556
+ .parserConfiguration({ "populate--": true })
543
557
  .strict()
544
- .usage('$0 <options> [command..]')
558
+ .usage("$0 <options> [command..]")
545
559
  .options(options)
546
- .example('$0 -i ./input.jpg -o ./out resize 300 200', 'out/input.jpg will be a 300 pixels wide and 200 pixels high image containing a scaled and cropped version of input.jpg')
547
- .example('$0 -i ./input.jpg -o ./out -mq90 rotate 180 -- resize 300 -- flatten "#ff6600" -- composite ./overlay.png --gravity southeast -- sharpen', 'out/input.jpg will be an upside down, 300px wide, alpha channel flattened onto orange background, composited with overlay.png with SE gravity, sharpened, with metadata, 90% quality version of input.jpg')
548
- .example('$0 -i ./input.jpg -o ./out --metadata', 'Include all metadata in the output image')
549
- .example('$0 -i ./input.jpg -o ./out --metadata.exif.IFD0.Copyright "Wernham Hogg"', 'Set "IFD0-Copyright" in output EXIF metadata')
550
- .example('$0 -i ./input.jpg -o ./out --metadata.density 96', 'Set output metadata to 96 DPI')
551
- .epilog('For more information on available options, please visit https://sharp.pixelplumbing.com/')
560
+ .example(
561
+ "$0 -i ./input.jpg -o ./out resize 300 200",
562
+ "out/input.jpg will be a 300 pixels wide and 200 pixels high image containing a scaled and cropped version of input.jpg",
563
+ )
564
+ .example(
565
+ '$0 -i ./input.jpg -o ./out -mq90 rotate 180 -- resize 300 -- flatten "#ff6600" -- composite ./overlay.png --gravity southeast -- sharpen',
566
+ "out/input.jpg will be an upside down, 300px wide, alpha channel flattened onto orange background, composited with overlay.png with SE gravity, sharpened, with metadata, 90% quality version of input.jpg",
567
+ )
568
+ .example(
569
+ "$0 -i ./input.jpg -o ./out --metadata",
570
+ "Include all metadata in the output image",
571
+ )
572
+ .example(
573
+ '$0 -i ./input.jpg -o ./out --metadata.exif.IFD0.Copyright "Wernham Hogg"',
574
+ 'Set "IFD0-Copyright" in output EXIF metadata',
575
+ )
576
+ .example(
577
+ "$0 -i ./input.jpg -o ./out --metadata.density 96",
578
+ "Set output metadata to 96 DPI",
579
+ )
580
+ .epilog(
581
+ "For more information on available options, please visit https://sharp.pixelplumbing.com/",
582
+ )
552
583
  .showHelpOnFail(false)
553
584
  .wrap(100)
554
585
 
555
586
  // Built-in options.
556
- .help().alias('help', 'h')
557
- .version(pkg.version).alias('version', 'v')
558
- .group(['help', 'version'], 'Misc. Options')
587
+ .help()
588
+ .alias("help", "h")
589
+ .version(pkg.version)
590
+ .alias("version", "v")
591
+ .group(["help", "version"], "Misc. Options")
559
592
 
560
593
  // Commands.
561
594
  // Avoid `yargs.commandDir()` as it uses insertion order, not alphabetical.
562
- .command(require('../cmd/operations/affine'))
563
- .command(require('../cmd/channel-manipulation/bandbool'))
564
- .command(require('../cmd/operations/blur'))
565
- .command(require('../cmd/operations/boolean'))
566
- .command(require('../cmd/operations/clahe'))
567
- .command(require('../cmd/compositing/composite'))
568
- .command(require('../cmd/operations/convolve'))
569
- .command(require('../cmd/channel-manipulation/ensure-alpha'))
570
- .command(require('../cmd/resizing/extend'))
571
- .command(require('../cmd/resizing/extract'))
572
- .command(require('../cmd/channel-manipulation/extract-channel'))
573
- .command(require('../cmd/operations/flatten'))
574
- .command(require('../cmd/operations/flip'))
575
- .command(require('../cmd/operations/flop'))
576
- .command(require('../cmd/operations/gamma'))
577
- .command(require('../cmd/colour-manipulation/greyscale'))
578
- .command(require('../cmd/channel-manipulation/join-channel'))
579
- .command(require('../cmd/operations/linear'))
580
- .command(require('../cmd/operations/median'))
581
- .command(require('../cmd/operations/modulate'))
582
- .command(require('../cmd/operations/negate'))
583
- .command(require('../cmd/operations/normalise'))
584
- .command(require('../cmd/colour-manipulation/pipeline-colourspace'))
585
- .command(require('../cmd/operations/recomb'))
586
- .command(require('../cmd/channel-manipulation/remove-alpha'))
587
- .command(require('../cmd/resizing/resize'))
588
- .command(require('../cmd/operations/rotate'))
589
- .command(require('../cmd/operations/sharpen'))
590
- .command(require('../cmd/operations/threshold'))
591
- .command(require('../cmd/colour-manipulation/tint'))
592
- .command(require('../cmd/output'))
593
- .command(require('../cmd/colour-manipulation/tocolourspace'))
594
- .command(require('../cmd/resizing/trim'))
595
- .command(require('../cmd/operations/unflatten'))
595
+ .command(require("../cmd/operations/affine"))
596
+ .command(require("../cmd/channel-manipulation/bandbool"))
597
+ .command(require("../cmd/operations/blur"))
598
+ .command(require("../cmd/operations/boolean"))
599
+ .command(require("../cmd/operations/clahe"))
600
+ .command(require("../cmd/compositing/composite"))
601
+ .command(require("../cmd/operations/convolve"))
602
+ .command(require("../cmd/operations/dilate"))
603
+ .command(require("../cmd/channel-manipulation/ensure-alpha"))
604
+ .command(require("../cmd/operations/erode"))
605
+ .command(require("../cmd/resizing/extend"))
606
+ .command(require("../cmd/resizing/extract"))
607
+ .command(require("../cmd/channel-manipulation/extract-channel"))
608
+ .command(require("../cmd/operations/flatten"))
609
+ .command(require("../cmd/operations/flip"))
610
+ .command(require("../cmd/operations/flop"))
611
+ .command(require("../cmd/operations/gamma"))
612
+ .command(require("../cmd/colour-manipulation/greyscale"))
613
+ .command(require("../cmd/channel-manipulation/join-channel"))
614
+ .command(require("../cmd/operations/linear"))
615
+ .command(require("../cmd/operations/median"))
616
+ .command(require("../cmd/operations/modulate"))
617
+ .command(require("../cmd/operations/negate"))
618
+ .command(require("../cmd/operations/normalise"))
619
+ .command(require("../cmd/colour-manipulation/pipeline-colourspace"))
620
+ .command(require("../cmd/operations/recomb"))
621
+ .command(require("../cmd/channel-manipulation/remove-alpha"))
622
+ .command(require("../cmd/resizing/resize"))
623
+ .command(require("../cmd/operations/rotate"))
624
+ .command(require("../cmd/operations/sharpen"))
625
+ .command(require("../cmd/operations/threshold"))
626
+ .command(require("../cmd/colour-manipulation/tint"))
627
+ .command(require("../cmd/output"))
628
+ .command(require("../cmd/colour-manipulation/tocolourspace"))
629
+ .command(require("../cmd/resizing/trim"))
630
+ .command(require("../cmd/operations/unflatten"));
596
631
 
597
632
  // Helpers.
598
- const originalParse = cli.parse.bind(cli)
633
+ const originalParse = cli.parse.bind(cli);
599
634
  const promisifiedParse = (...args) => {
600
635
  return new Promise((resolve, reject) => {
601
636
  originalParse(...args, (err, argv, output) => {
602
637
  if (err) {
603
- reject(err)
638
+ reject(err);
604
639
  }
605
640
  if (argv.v || argv.help) {
606
- reject(output)
641
+ reject(output);
607
642
  }
608
- resolve(argv)
609
- })
610
- })
611
- }
643
+ resolve(argv);
644
+ });
645
+ });
646
+ };
612
647
 
613
648
  // Exports.
614
- module.exports = cli
615
- module.exports.inputOptions = Object.keys(inputOptions)
616
- module.exports.parse = function recursiveParse (args, context = {}) {
617
- return promisifiedParse(args, context).then(argv => {
649
+ module.exports = cli;
650
+ module.exports.inputOptions = Object.keys(inputOptions);
651
+ module.exports.parse = function recursiveParse(args, context = {}) {
652
+ return promisifiedParse(args, context).then((argv) => {
618
653
  // Handle arguments.
619
654
  // NOTE Use queue.unshift to apply global options first.
620
655
 
@@ -623,74 +658,115 @@ module.exports.parse = function recursiveParse (args, context = {}) {
623
658
  // Require at least one input file.
624
659
  // NOTE: check here b/c https://github.com/yargs/yargs/issues/403
625
660
  if (argv.input && argv.input.length === 0) {
626
- throw new Error('Not enough arguments following: i, input')
661
+ throw new Error("Not enough arguments following: i, input");
627
662
  }
628
663
 
629
664
  // @see https://sharp.pixelplumbing.com/api-output#timeout
630
665
  if (argv.timeout) {
631
- queue.unshift(['timeout', (sharp) => sharp.timeout({ seconds: argv.timeout })])
666
+ queue.unshift([
667
+ "timeout",
668
+ (sharp) => sharp.timeout({ seconds: argv.timeout }),
669
+ ]);
632
670
  }
633
671
 
634
672
  // Output options.
635
673
 
636
674
  // @see https://sharp.pixelplumbing.com/api-output#toformat
637
675
  if (argv.format) {
638
- queue.unshift(['format', (sharp) => sharp.toFormat(argv.format, { compression: argv.hcompression })])
676
+ queue.unshift([
677
+ "format",
678
+ (sharp) =>
679
+ sharp.toFormat(argv.format, { compression: argv.hcompression }),
680
+ ]);
639
681
  }
640
682
 
641
683
  // @see https://sharp.pixelplumbing.com/api-output#withmetadata
642
684
  if (argv.metadata) {
643
- queue.unshift(['withMetadata', (sharp) => sharp.withMetadata(argv.metadata)])
685
+ queue.unshift([
686
+ "withMetadata",
687
+ (sharp) => sharp.withMetadata(argv.metadata),
688
+ ]);
644
689
  }
645
690
 
646
691
  // @see https://sharp.pixelplumbing.com/api-output#heif
647
- const { heif } = sharp.format
648
- if (argv.hcompression !== optimizationOptions.hcompression.default || // HEIF-specific.
692
+ const { heif } = sharp.format;
693
+ if (
694
+ argv.hcompression !== optimizationOptions.hcompression.default || // HEIF-specific.
649
695
  // Ensure libheif is installed before applying generic options.
650
- (heif.input && heif.input.file &&
651
- (argv.effort || argv.hbitdepth || argv.lossless || argv.quality))) {
652
- queue.unshift(['heif', (sharp) => {
653
- return sharp.heif({
654
- bitdepth: argv.hbitdepth,
655
- compression: argv.hcompression,
656
- effort: argv.effort,
657
- force: false,
658
- lossless: argv.lossless,
659
- quality: argv.quality
660
- })
661
- }])
696
+ (heif.input &&
697
+ heif.input.file &&
698
+ (argv.effort !== undefined ||
699
+ argv.hbitdepth ||
700
+ argv.lossless ||
701
+ argv.quality))
702
+ ) {
703
+ queue.unshift([
704
+ "heif",
705
+ (sharp) => {
706
+ return sharp.heif({
707
+ bitdepth: argv.hbitdepth,
708
+ compression: argv.hcompression,
709
+ effort: argv.effort,
710
+ force: false,
711
+ lossless: argv.lossless,
712
+ quality: argv.quality,
713
+ });
714
+ },
715
+ ]);
662
716
  }
663
717
 
664
718
  // @see https://sharp.pixelplumbing.com/api-output#avif
665
- if (argv.chromaSubsampling || argv.effort || argv.lossless || argv.quality) {
666
- queue.unshift(['avif', (sharp) => {
667
- return sharp.avif({
668
- chromaSubsampling: argv.chromaSubsampling,
669
- effort: argv.effort,
670
- force: false,
671
- lossless: argv.lossless,
672
- quality: argv.quality
673
- })
674
- }])
719
+ if (
720
+ argv.chromaSubsampling ||
721
+ argv.effort !== undefined ||
722
+ argv.lossless ||
723
+ argv.quality
724
+ ) {
725
+ queue.unshift([
726
+ "avif",
727
+ (sharp) => {
728
+ return sharp.avif({
729
+ chromaSubsampling: argv.chromaSubsampling,
730
+ effort: argv.effort,
731
+ force: false,
732
+ lossless: argv.lossless,
733
+ quality: argv.quality,
734
+ });
735
+ },
736
+ ]);
675
737
  }
676
738
 
677
739
  // @see https://sharp.pixelplumbing.com/api-output#gif
678
- if (argv.colors || argv.effort || argv.dither || argv.interFrameMaxError ||
679
- argv.interPaletteMaxError || argv.loop || argv.delay || argv.progressive || argv.reuse) {
680
- queue.unshift(['gif', (sharp) => {
681
- return sharp.gif({
682
- colors: argv.colors,
683
- force: false,
684
- effort: argv.effort,
685
- dither: argv.dither,
686
- interFrameMaxError: argv.interFrameMaxError,
687
- interPaletteMaxError: argv.interPaletteMaxError,
688
- loop: argv.loop,
689
- delay: argv.delay,
690
- progressive: argv.progressive,
691
- reuse: argv.reuse
692
- })
693
- }])
740
+ if (
741
+ argv.colors ||
742
+ argv.effort !== undefined ||
743
+ argv.dither !== undefined ||
744
+ argv.interFrameMaxError ||
745
+ argv.interPaletteMaxError ||
746
+ argv.keepDuplicateFrames ||
747
+ argv.loop ||
748
+ argv.delay !== undefined ||
749
+ argv.progressive ||
750
+ argv.reuse
751
+ ) {
752
+ queue.unshift([
753
+ "gif",
754
+ (sharp) => {
755
+ return sharp.gif({
756
+ colors: argv.colors,
757
+ force: false,
758
+ effort: argv.effort,
759
+ dither: argv.dither,
760
+ interFrameMaxError: argv.interFrameMaxError,
761
+ interPaletteMaxError: argv.interPaletteMaxError,
762
+ keepDuplicateFrames: argv.keepDuplicateFrames,
763
+ loop: argv.loop,
764
+ delay: argv.delay,
765
+ progressive: argv.progressive,
766
+ reuse: argv.reuse,
767
+ });
768
+ },
769
+ ]);
694
770
  }
695
771
 
696
772
  // @see https://sharp.pixelplumbing.com/api-output#jpeg
@@ -706,95 +782,133 @@ module.exports.parse = function recursiveParse (args, context = {}) {
706
782
  argv.quality ||
707
783
  argv.trellisQuantisation
708
784
  ) {
709
- queue.unshift(['jpeg', (sharp) => {
710
- return sharp.jpeg({
711
- chromaSubsampling: argv.chromaSubsampling,
712
- force: false,
713
- mozjpeg: argv.mozjpeg,
714
- optimiseCoding: argv.optimiseCoding,
715
- optimiseScans: argv.optimise || argv.optimiseScans,
716
- overshootDeringing: argv.optimise || argv.overshootDeringing,
717
- progressive: argv.progressive,
718
- quality: argv.quality,
719
- quantisationTable: argv.quantisationTable,
720
- trellisQuantisation: argv.optimise || argv.trellisQuantisation
721
- })
722
- }])
785
+ queue.unshift([
786
+ "jpeg",
787
+ (sharp) => {
788
+ return sharp.jpeg({
789
+ chromaSubsampling: argv.chromaSubsampling,
790
+ force: false,
791
+ mozjpeg: argv.mozjpeg,
792
+ optimiseCoding: argv.optimiseCoding,
793
+ optimiseScans: argv.optimise || argv.optimiseScans,
794
+ overshootDeringing: argv.optimise || argv.overshootDeringing,
795
+ progressive: argv.progressive,
796
+ quality: argv.quality,
797
+ quantisationTable: argv.quantisationTable,
798
+ trellisQuantisation: argv.optimise || argv.trellisQuantisation,
799
+ });
800
+ },
801
+ ]);
723
802
  }
724
803
 
725
804
  // @see https://sharp.pixelplumbing.com/api-output#png
726
- if (argv.adaptiveFiltering || argv.colors || argv.compressionLevel ||
727
- argv.dither || argv.effort || argv.palette || argv.progressive) {
728
- queue.unshift(['png', (sharp) => {
729
- return sharp.png({
730
- adaptiveFiltering: argv.adaptiveFiltering,
731
- colors: argv.colors,
732
- compressionLevel: argv.compressionLevel,
733
- dither: argv.dither,
734
- effort: argv.effort,
735
- force: false,
736
- palette: argv.palette,
737
- progressive: argv.progressive
738
- })
739
- }])
805
+ if (
806
+ argv.adaptiveFiltering ||
807
+ argv.colors ||
808
+ argv.compressionLevel !== undefined ||
809
+ argv.dither !== undefined ||
810
+ argv.effort ||
811
+ argv.palette ||
812
+ argv.progressive
813
+ ) {
814
+ queue.unshift([
815
+ "png",
816
+ (sharp) => {
817
+ return sharp.png({
818
+ adaptiveFiltering: argv.adaptiveFiltering,
819
+ colors: argv.colors,
820
+ compressionLevel: argv.compressionLevel,
821
+ dither: argv.dither,
822
+ effort: argv.effort,
823
+ force: false,
824
+ palette: argv.palette,
825
+ progressive: argv.progressive,
826
+ });
827
+ },
828
+ ]);
740
829
  }
741
830
 
742
831
  // @see https://sharp.pixelplumbing.com/api-output#tiff
743
- if (argv.bitdepth ||
832
+ if (
833
+ argv.bigtiff ||
834
+ argv.bitdepth ||
744
835
  argv.compression !== optimizationOptions.compression.default ||
745
836
  argv.predictor !== optimizationOptions.predictor.default ||
746
- argv.miniswhite || argv.pyramid || argv.quality || argv.resolutionUnit ||
747
- argv.tileBackground || argv.tileHeight || argv.tileWidth || argv.xres || argv.yres) {
748
- queue.unshift(['tiff', (sharp) => {
749
- return sharp.tiff({
750
- background: argv.tileBackground,
751
- bitdepth: argv.bitdepth,
752
- compression: argv.compression,
753
- force: false,
754
- miniswhite: argv.miniswhite,
755
- predictor: argv.predictor,
756
- pyramid: argv.pyramid,
757
- quality: argv.quality,
758
- resolutionUnit: argv.resolutionUnit,
759
- tile: argv.tileWidth !== undefined || argv.tileHeight !== undefined,
760
- tileHeight: argv.tileHeight || argv.tileWidth,
761
- tileWidth: argv.tileWidth || argv.tileHeight,
762
- xres: argv.xres,
763
- yres: argv.yres
764
- })
765
- }])
837
+ argv.miniswhite ||
838
+ argv.pyramid ||
839
+ argv.quality ||
840
+ argv.resolutionUnit ||
841
+ argv.tileBackground ||
842
+ argv.tileHeight ||
843
+ argv.tileWidth ||
844
+ argv.xres ||
845
+ argv.yres
846
+ ) {
847
+ queue.unshift([
848
+ "tiff",
849
+ (sharp) => {
850
+ return sharp.tiff({
851
+ background: argv.tileBackground,
852
+ bigtiff: argv.bigtiff,
853
+ bitdepth: argv.bitdepth,
854
+ compression: argv.compression,
855
+ force: false,
856
+ miniswhite: argv.miniswhite,
857
+ predictor: argv.predictor,
858
+ pyramid: argv.pyramid,
859
+ quality: argv.quality,
860
+ resolutionUnit: argv.resolutionUnit,
861
+ tile: argv.tileWidth !== undefined || argv.tileHeight !== undefined,
862
+ tileHeight: argv.tileHeight || argv.tileWidth,
863
+ tileWidth: argv.tileWidth || argv.tileHeight,
864
+ xres: argv.xres,
865
+ yres: argv.yres,
866
+ });
867
+ },
868
+ ]);
766
869
  }
767
870
 
768
871
  // @see https://sharp.pixelplumbing.com/api-output#webp
769
- if (argv.alphaQuality || argv.quality || argv.lossless || argv.minSize ||
770
- argv.mixed || argv.nearLossless || argv.effort ||
771
- argv.preset !== optimizationOptions.preset.default || argv.smartDeblock ||
772
- argv.smartSubsample) {
773
- queue.unshift(['webp', (sharp) => {
774
- return sharp.webp({
775
- alphaQuality: argv.alphaQuality,
776
- effort: argv.effort,
777
- force: false,
778
- lossless: argv.lossless,
779
- minSize: argv.minSize,
780
- mixed: argv.mixed,
781
- nearLossless: argv.nearLossless,
782
- preset: argv.preset,
783
- quality: argv.quality,
784
- smartDeblock: argv.smartDeblock,
785
- smartSubsample: argv.smartSubsample
786
- })
787
- }])
872
+ if (
873
+ argv.alphaQuality ||
874
+ argv.quality ||
875
+ argv.lossless ||
876
+ argv.minSize ||
877
+ argv.mixed ||
878
+ argv.nearLossless ||
879
+ argv.effort !== undefined ||
880
+ argv.preset !== optimizationOptions.preset.default ||
881
+ argv.smartDeblock ||
882
+ argv.smartSubsample
883
+ ) {
884
+ queue.unshift([
885
+ "webp",
886
+ (sharp) => {
887
+ return sharp.webp({
888
+ alphaQuality: argv.alphaQuality,
889
+ effort: argv.effort,
890
+ force: false,
891
+ lossless: argv.lossless,
892
+ minSize: argv.minSize,
893
+ mixed: argv.mixed,
894
+ nearLossless: argv.nearLossless,
895
+ preset: argv.preset,
896
+ quality: argv.quality,
897
+ smartDeblock: argv.smartDeblock,
898
+ smartSubsample: argv.smartSubsample,
899
+ });
900
+ },
901
+ ]);
788
902
  }
789
903
 
790
904
  // Invoke with remaining arguments (if any).
791
- const { '--': remainingargv = [] } = argv
905
+ const { "--": remainingargv = [] } = argv;
792
906
  if (remainingargv.length > 0) {
793
907
  return recursiveParse(remainingargv, {
794
908
  ...context,
795
- ...pick(argv, Object.keys(options)) // Retain options.
796
- })
909
+ ...pick(argv, Object.keys(options)), // Retain options.
910
+ });
797
911
  }
798
- return argv
799
- })
800
- }
912
+ return argv;
913
+ });
914
+ };