spec-cat 0.1.0 → 0.1.2

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 (110) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/{Bqlz6CoK.js → BE_75kPa.js} +1 -1
  3. package/.output/public/_nuxt/{B2wdmh_w.js → BJ7m4fRW.js} +53 -53
  4. package/.output/public/_nuxt/{KNuzSjk0.js → CCNYUZ9m.js} +1 -1
  5. package/.output/public/_nuxt/{BvosqTnx.js → DGtcdWVl.js} +1 -1
  6. package/.output/public/_nuxt/DxEx-kFx.js +1 -0
  7. package/.output/public/_nuxt/{BwcbSlWF.js → DyMq_cQC.js} +2 -2
  8. package/.output/public/_nuxt/{COTT6rNZ.js → _cj5lOdZ.js} +1 -1
  9. package/.output/public/_nuxt/builds/latest.json +1 -1
  10. package/.output/public/_nuxt/builds/meta/3a0aacc1-0bd1-4d15-8b8a-3cee48cbfc69.json +1 -0
  11. package/.output/public/_nuxt/{BUOk7wkI.js → gDut6QrP.js} +1 -1
  12. package/.output/public/_nuxt/{C5wk2twv.js → nJpWpjzg.js} +1 -1
  13. package/.output/public/_nuxt/{DBab5Zcv.js → waQ9fPC1.js} +1 -1
  14. package/.output/server/chunks/_/codexProvider.mjs +64 -18
  15. package/.output/server/chunks/_/codexProvider.mjs.map +1 -1
  16. package/.output/server/chunks/build/client.precomputed.mjs +1 -1
  17. package/.output/server/chunks/build/client.precomputed.mjs.map +1 -1
  18. package/.output/server/chunks/nitro/nitro.mjs +702 -703
  19. package/.output/server/chunks/routes/_ws.mjs +37 -7
  20. package/.output/server/chunks/routes/_ws.mjs.map +1 -1
  21. package/.output/server/node_modules/@huggingface/jinja/dist/index.js +1572 -0
  22. package/.output/server/node_modules/@huggingface/jinja/package.json +55 -0
  23. package/.output/server/node_modules/@xenova/transformers/package.json +84 -0
  24. package/.output/server/node_modules/@xenova/transformers/src/backends/onnx.js +50 -0
  25. package/.output/server/node_modules/@xenova/transformers/src/configs.js +107 -0
  26. package/.output/server/node_modules/@xenova/transformers/src/env.js +128 -0
  27. package/.output/server/node_modules/@xenova/transformers/src/models.js +6267 -0
  28. package/.output/server/node_modules/@xenova/transformers/src/pipelines.js +3287 -0
  29. package/.output/server/node_modules/@xenova/transformers/src/processors.js +2248 -0
  30. package/.output/server/node_modules/@xenova/transformers/src/tokenizers.js +4479 -0
  31. package/.output/server/node_modules/@xenova/transformers/src/transformers.js +24 -0
  32. package/.output/server/node_modules/@xenova/transformers/src/utils/audio.js +672 -0
  33. package/.output/server/node_modules/@xenova/transformers/src/utils/core.js +175 -0
  34. package/.output/server/node_modules/@xenova/transformers/src/utils/data-structures.js +415 -0
  35. package/.output/server/node_modules/@xenova/transformers/src/utils/generation.js +873 -0
  36. package/.output/server/node_modules/@xenova/transformers/src/utils/hub.js +658 -0
  37. package/.output/server/node_modules/@xenova/transformers/src/utils/image.js +731 -0
  38. package/.output/server/node_modules/@xenova/transformers/src/utils/maths.js +985 -0
  39. package/.output/server/node_modules/@xenova/transformers/src/utils/tensor.js +1239 -0
  40. package/.output/server/node_modules/color/index.js +496 -0
  41. package/.output/server/node_modules/color/package.json +47 -0
  42. package/.output/server/node_modules/color-convert/conversions.js +839 -0
  43. package/.output/server/node_modules/color-convert/index.js +81 -0
  44. package/.output/server/node_modules/color-convert/package.json +48 -0
  45. package/.output/server/node_modules/color-convert/route.js +97 -0
  46. package/.output/server/node_modules/color-name/index.js +152 -0
  47. package/.output/server/node_modules/color-name/package.json +28 -0
  48. package/.output/server/node_modules/color-string/index.js +242 -0
  49. package/.output/server/node_modules/color-string/package.json +39 -0
  50. package/.output/server/node_modules/detect-libc/lib/detect-libc.js +313 -0
  51. package/.output/server/node_modules/detect-libc/lib/elf.js +39 -0
  52. package/.output/server/node_modules/detect-libc/lib/filesystem.js +51 -0
  53. package/.output/server/node_modules/detect-libc/lib/process.js +24 -0
  54. package/.output/server/node_modules/detect-libc/package.json +44 -0
  55. package/.output/server/node_modules/is-arrayish/index.js +9 -0
  56. package/.output/server/node_modules/is-arrayish/package.json +45 -0
  57. package/.output/server/node_modules/onnxruntime-common/dist/ort-common.node.js +7 -0
  58. package/.output/server/node_modules/onnxruntime-common/package.json +31 -0
  59. package/.output/server/node_modules/onnxruntime-node/bin/napi-v3/darwin/arm64/onnxruntime_binding.node +0 -0
  60. package/.output/server/node_modules/onnxruntime-node/bin/napi-v3/darwin/x64/onnxruntime_binding.node +0 -0
  61. package/.output/server/node_modules/onnxruntime-node/bin/napi-v3/linux/arm64/libonnxruntime.so.1.14.0 +0 -0
  62. package/.output/server/node_modules/onnxruntime-node/bin/napi-v3/linux/arm64/onnxruntime_binding.node +0 -0
  63. package/.output/server/node_modules/onnxruntime-node/bin/napi-v3/linux/x64/libonnxruntime.so.1.14.0 +0 -0
  64. package/.output/server/node_modules/onnxruntime-node/bin/napi-v3/linux/x64/onnxruntime_binding.node +0 -0
  65. package/.output/server/node_modules/onnxruntime-node/bin/napi-v3/win32/arm64/onnxruntime_binding.node +0 -0
  66. package/.output/server/node_modules/onnxruntime-node/bin/napi-v3/win32/x64/onnxruntime_binding.node +0 -0
  67. package/.output/server/node_modules/onnxruntime-node/dist/backend.js +75 -0
  68. package/.output/server/node_modules/onnxruntime-node/dist/binding.js +10 -0
  69. package/.output/server/node_modules/onnxruntime-node/dist/index.js +23 -0
  70. package/.output/server/node_modules/onnxruntime-node/package.json +58 -0
  71. package/.output/server/node_modules/onnxruntime-web/dist/ort-web.node.js +7 -0
  72. package/.output/server/node_modules/onnxruntime-web/package.json +84 -0
  73. package/.output/server/node_modules/semver/classes/semver.js +333 -0
  74. package/.output/server/node_modules/semver/functions/coerce.js +62 -0
  75. package/.output/server/node_modules/semver/functions/compare.js +7 -0
  76. package/.output/server/node_modules/semver/functions/gte.js +5 -0
  77. package/.output/server/node_modules/semver/functions/parse.js +18 -0
  78. package/.output/server/node_modules/semver/internal/constants.js +37 -0
  79. package/.output/server/node_modules/semver/internal/debug.js +11 -0
  80. package/.output/server/node_modules/semver/internal/identifiers.js +29 -0
  81. package/.output/server/node_modules/semver/internal/parse-options.js +17 -0
  82. package/.output/server/node_modules/semver/internal/re.js +223 -0
  83. package/.output/server/node_modules/semver/package.json +78 -0
  84. package/.output/server/node_modules/sharp/build/Release/sharp-linux-x64.node +0 -0
  85. package/.output/server/node_modules/sharp/lib/channel.js +174 -0
  86. package/.output/server/node_modules/sharp/lib/colour.js +184 -0
  87. package/.output/server/node_modules/sharp/lib/composite.js +210 -0
  88. package/.output/server/node_modules/sharp/lib/constructor.js +439 -0
  89. package/.output/server/node_modules/sharp/lib/index.js +16 -0
  90. package/.output/server/node_modules/sharp/lib/input.js +631 -0
  91. package/.output/server/node_modules/sharp/lib/is.js +155 -0
  92. package/.output/server/node_modules/sharp/lib/libvips.js +140 -0
  93. package/.output/server/node_modules/sharp/lib/operation.js +919 -0
  94. package/.output/server/node_modules/sharp/lib/output.js +1413 -0
  95. package/.output/server/node_modules/sharp/lib/platform.js +30 -0
  96. package/.output/server/node_modules/sharp/lib/resize.js +582 -0
  97. package/.output/server/node_modules/sharp/lib/sharp.js +38 -0
  98. package/.output/server/node_modules/sharp/lib/utility.js +287 -0
  99. package/.output/server/node_modules/sharp/package.json +204 -0
  100. package/.output/server/node_modules/sharp/vendor/8.14.5/linux-x64/THIRD-PARTY-NOTICES.md +43 -0
  101. package/.output/server/node_modules/sharp/vendor/8.14.5/linux-x64/lib/libvips-cpp.so.42 +0 -0
  102. package/.output/server/node_modules/sharp/vendor/8.14.5/linux-x64/platform.json +1 -0
  103. package/.output/server/node_modules/sharp/vendor/8.14.5/linux-x64/versions.json +31 -0
  104. package/.output/server/node_modules/simple-swizzle/index.js +29 -0
  105. package/.output/server/node_modules/simple-swizzle/package.json +36 -0
  106. package/.output/server/package.json +15 -1
  107. package/README.md +2 -0
  108. package/package.json +12 -19
  109. package/.output/public/_nuxt/5FxpIoe_.js +0 -1
  110. package/.output/public/_nuxt/builds/meta/21578a05-1b7e-4847-a8ff-7480800ea4a6.json +0 -1
@@ -0,0 +1,1413 @@
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const path = require('path');
7
+ const is = require('./is');
8
+ const sharp = require('./sharp');
9
+
10
+ const formats = new Map([
11
+ ['heic', 'heif'],
12
+ ['heif', 'heif'],
13
+ ['avif', 'avif'],
14
+ ['jpeg', 'jpeg'],
15
+ ['jpg', 'jpeg'],
16
+ ['jpe', 'jpeg'],
17
+ ['tile', 'tile'],
18
+ ['dz', 'tile'],
19
+ ['png', 'png'],
20
+ ['raw', 'raw'],
21
+ ['tiff', 'tiff'],
22
+ ['tif', 'tiff'],
23
+ ['webp', 'webp'],
24
+ ['gif', 'gif'],
25
+ ['jp2', 'jp2'],
26
+ ['jpx', 'jp2'],
27
+ ['j2k', 'jp2'],
28
+ ['j2c', 'jp2'],
29
+ ['jxl', 'jxl']
30
+ ]);
31
+
32
+ const jp2Regex = /\.(jp[2x]|j2[kc])$/i;
33
+
34
+ const errJp2Save = () => new Error('JP2 output requires libvips with support for OpenJPEG');
35
+
36
+ const bitdepthFromColourCount = (colours) => 1 << 31 - Math.clz32(Math.ceil(Math.log2(colours)));
37
+
38
+ /**
39
+ * Write output image data to a file.
40
+ *
41
+ * If an explicit output format is not selected, it will be inferred from the extension,
42
+ * with JPEG, PNG, WebP, AVIF, TIFF, GIF, DZI, and libvips' V format supported.
43
+ * Note that raw pixel data is only supported for buffer output.
44
+ *
45
+ * By default all metadata will be removed, which includes EXIF-based orientation.
46
+ * See {@link #withmetadata|withMetadata} for control over this.
47
+ *
48
+ * The caller is responsible for ensuring directory structures and permissions exist.
49
+ *
50
+ * A `Promise` is returned when `callback` is not provided.
51
+ *
52
+ * @example
53
+ * sharp(input)
54
+ * .toFile('output.png', (err, info) => { ... });
55
+ *
56
+ * @example
57
+ * sharp(input)
58
+ * .toFile('output.png')
59
+ * .then(info => { ... })
60
+ * .catch(err => { ... });
61
+ *
62
+ * @param {string} fileOut - the path to write the image data to.
63
+ * @param {Function} [callback] - called on completion with two arguments `(err, info)`.
64
+ * `info` contains the output image `format`, `size` (bytes), `width`, `height`,
65
+ * `channels` and `premultiplied` (indicating if premultiplication was used).
66
+ * When using a crop strategy also contains `cropOffsetLeft` and `cropOffsetTop`.
67
+ * When using the attention crop strategy also contains `attentionX` and `attentionY`, the focal point of the cropped region.
68
+ * May also contain `textAutofitDpi` (dpi the font was rendered at) if image was created from text.
69
+ * @returns {Promise<Object>} - when no callback is provided
70
+ * @throws {Error} Invalid parameters
71
+ */
72
+ function toFile (fileOut, callback) {
73
+ let err;
74
+ if (!is.string(fileOut)) {
75
+ err = new Error('Missing output file path');
76
+ } else if (is.string(this.options.input.file) && path.resolve(this.options.input.file) === path.resolve(fileOut)) {
77
+ err = new Error('Cannot use same file for input and output');
78
+ } else if (jp2Regex.test(path.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
79
+ err = errJp2Save();
80
+ }
81
+ if (err) {
82
+ if (is.fn(callback)) {
83
+ callback(err);
84
+ } else {
85
+ return Promise.reject(err);
86
+ }
87
+ } else {
88
+ this.options.fileOut = fileOut;
89
+ return this._pipeline(callback);
90
+ }
91
+ return this;
92
+ }
93
+
94
+ /**
95
+ * Write output to a Buffer.
96
+ * JPEG, PNG, WebP, AVIF, TIFF, GIF and raw pixel data output are supported.
97
+ *
98
+ * Use {@link #toformat|toFormat} or one of the format-specific functions such as {@link jpeg}, {@link png} etc. to set the output format.
99
+ *
100
+ * If no explicit format is set, the output format will match the input image, except SVG input which becomes PNG output.
101
+ *
102
+ * By default all metadata will be removed, which includes EXIF-based orientation.
103
+ * See {@link #withmetadata|withMetadata} for control over this.
104
+ *
105
+ * `callback`, if present, gets three arguments `(err, data, info)` where:
106
+ * - `err` is an error, if any.
107
+ * - `data` is the output image data.
108
+ * - `info` contains the output image `format`, `size` (bytes), `width`, `height`,
109
+ * `channels` and `premultiplied` (indicating if premultiplication was used).
110
+ * When using a crop strategy also contains `cropOffsetLeft` and `cropOffsetTop`.
111
+ * May also contain `textAutofitDpi` (dpi the font was rendered at) if image was created from text.
112
+ *
113
+ * A `Promise` is returned when `callback` is not provided.
114
+ *
115
+ * @example
116
+ * sharp(input)
117
+ * .toBuffer((err, data, info) => { ... });
118
+ *
119
+ * @example
120
+ * sharp(input)
121
+ * .toBuffer()
122
+ * .then(data => { ... })
123
+ * .catch(err => { ... });
124
+ *
125
+ * @example
126
+ * sharp(input)
127
+ * .png()
128
+ * .toBuffer({ resolveWithObject: true })
129
+ * .then(({ data, info }) => { ... })
130
+ * .catch(err => { ... });
131
+ *
132
+ * @example
133
+ * const { data, info } = await sharp('my-image.jpg')
134
+ * // output the raw pixels
135
+ * .raw()
136
+ * .toBuffer({ resolveWithObject: true });
137
+ *
138
+ * // create a more type safe way to work with the raw pixel data
139
+ * // this will not copy the data, instead it will change `data`s underlying ArrayBuffer
140
+ * // so `data` and `pixelArray` point to the same memory location
141
+ * const pixelArray = new Uint8ClampedArray(data.buffer);
142
+ *
143
+ * // When you are done changing the pixelArray, sharp takes the `pixelArray` as an input
144
+ * const { width, height, channels } = info;
145
+ * await sharp(pixelArray, { raw: { width, height, channels } })
146
+ * .toFile('my-changed-image.jpg');
147
+ *
148
+ * @param {Object} [options]
149
+ * @param {boolean} [options.resolveWithObject] Resolve the Promise with an Object containing `data` and `info` properties instead of resolving only with `data`.
150
+ * @param {Function} [callback]
151
+ * @returns {Promise<Buffer>} - when no callback is provided
152
+ */
153
+ function toBuffer (options, callback) {
154
+ if (is.object(options)) {
155
+ this._setBooleanOption('resolveWithObject', options.resolveWithObject);
156
+ } else if (this.options.resolveWithObject) {
157
+ this.options.resolveWithObject = false;
158
+ }
159
+ this.options.fileOut = '';
160
+ return this._pipeline(is.fn(options) ? options : callback);
161
+ }
162
+
163
+ /**
164
+ * Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
165
+ * This will also convert to and add a web-friendly sRGB ICC profile if appropriate,
166
+ * unless a custom output profile is provided.
167
+ *
168
+ * The default behaviour, when `withMetadata` is not used, is to convert to the device-independent
169
+ * sRGB colour space and strip all metadata, including the removal of any ICC profile.
170
+ *
171
+ * EXIF metadata is unsupported for TIFF output.
172
+ *
173
+ * @example
174
+ * sharp('input.jpg')
175
+ * .withMetadata()
176
+ * .toFile('output-with-metadata.jpg')
177
+ * .then(info => { ... });
178
+ *
179
+ * @example
180
+ * // Set output EXIF metadata
181
+ * const data = await sharp(input)
182
+ * .withMetadata({
183
+ * exif: {
184
+ * IFD0: {
185
+ * Copyright: 'The National Gallery'
186
+ * },
187
+ * IFD3: {
188
+ * GPSLatitudeRef: 'N',
189
+ * GPSLatitude: '51/1 30/1 3230/100',
190
+ * GPSLongitudeRef: 'W',
191
+ * GPSLongitude: '0/1 7/1 4366/100'
192
+ * }
193
+ * }
194
+ * })
195
+ * .toBuffer();
196
+ *
197
+ * @example
198
+ * // Set output metadata to 96 DPI
199
+ * const data = await sharp(input)
200
+ * .withMetadata({ density: 96 })
201
+ * .toBuffer();
202
+ *
203
+ * @param {Object} [options]
204
+ * @param {number} [options.orientation] value between 1 and 8, used to update the EXIF `Orientation` tag.
205
+ * @param {string} [options.icc='srgb'] Filesystem path to output ICC profile, relative to `process.cwd()`, defaults to built-in sRGB.
206
+ * @param {Object<Object>} [options.exif={}] Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data.
207
+ * @param {number} [options.density] Number of pixels per inch (DPI).
208
+ * @returns {Sharp}
209
+ * @throws {Error} Invalid parameters
210
+ */
211
+ function withMetadata (options) {
212
+ this.options.withMetadata = is.bool(options) ? options : true;
213
+ if (is.object(options)) {
214
+ if (is.defined(options.orientation)) {
215
+ if (is.integer(options.orientation) && is.inRange(options.orientation, 1, 8)) {
216
+ this.options.withMetadataOrientation = options.orientation;
217
+ } else {
218
+ throw is.invalidParameterError('orientation', 'integer between 1 and 8', options.orientation);
219
+ }
220
+ }
221
+ if (is.defined(options.density)) {
222
+ if (is.number(options.density) && options.density > 0) {
223
+ this.options.withMetadataDensity = options.density;
224
+ } else {
225
+ throw is.invalidParameterError('density', 'positive number', options.density);
226
+ }
227
+ }
228
+ if (is.defined(options.icc)) {
229
+ if (is.string(options.icc)) {
230
+ this.options.withMetadataIcc = options.icc;
231
+ } else {
232
+ throw is.invalidParameterError('icc', 'string filesystem path to ICC profile', options.icc);
233
+ }
234
+ }
235
+ if (is.defined(options.exif)) {
236
+ if (is.object(options.exif)) {
237
+ for (const [ifd, entries] of Object.entries(options.exif)) {
238
+ if (is.object(entries)) {
239
+ for (const [k, v] of Object.entries(entries)) {
240
+ if (is.string(v)) {
241
+ this.options.withMetadataStrs[`exif-${ifd.toLowerCase()}-${k}`] = v;
242
+ } else {
243
+ throw is.invalidParameterError(`exif.${ifd}.${k}`, 'string', v);
244
+ }
245
+ }
246
+ } else {
247
+ throw is.invalidParameterError(`exif.${ifd}`, 'object', entries);
248
+ }
249
+ }
250
+ } else {
251
+ throw is.invalidParameterError('exif', 'object', options.exif);
252
+ }
253
+ }
254
+ }
255
+ return this;
256
+ }
257
+
258
+ /**
259
+ * Force output to a given format.
260
+ *
261
+ * @example
262
+ * // Convert any input to PNG output
263
+ * const data = await sharp(input)
264
+ * .toFormat('png')
265
+ * .toBuffer();
266
+ *
267
+ * @param {(string|Object)} format - as a string or an Object with an 'id' attribute
268
+ * @param {Object} options - output options
269
+ * @returns {Sharp}
270
+ * @throws {Error} unsupported format or options
271
+ */
272
+ function toFormat (format, options) {
273
+ const actualFormat = formats.get((is.object(format) && is.string(format.id) ? format.id : format).toLowerCase());
274
+ if (!actualFormat) {
275
+ throw is.invalidParameterError('format', `one of: ${[...formats.keys()].join(', ')}`, format);
276
+ }
277
+ return this[actualFormat](options);
278
+ }
279
+
280
+ /**
281
+ * Use these JPEG options for output image.
282
+ *
283
+ * @example
284
+ * // Convert any input to very high quality JPEG output
285
+ * const data = await sharp(input)
286
+ * .jpeg({
287
+ * quality: 100,
288
+ * chromaSubsampling: '4:4:4'
289
+ * })
290
+ * .toBuffer();
291
+ *
292
+ * @example
293
+ * // Use mozjpeg to reduce output JPEG file size (slower)
294
+ * const data = await sharp(input)
295
+ * .jpeg({ mozjpeg: true })
296
+ * .toBuffer();
297
+ *
298
+ * @param {Object} [options] - output options
299
+ * @param {number} [options.quality=80] - quality, integer 1-100
300
+ * @param {boolean} [options.progressive=false] - use progressive (interlace) scan
301
+ * @param {string} [options.chromaSubsampling='4:2:0'] - set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling
302
+ * @param {boolean} [options.optimiseCoding=true] - optimise Huffman coding tables
303
+ * @param {boolean} [options.optimizeCoding=true] - alternative spelling of optimiseCoding
304
+ * @param {boolean} [options.mozjpeg=false] - use mozjpeg defaults, equivalent to `{ trellisQuantisation: true, overshootDeringing: true, optimiseScans: true, quantisationTable: 3 }`
305
+ * @param {boolean} [options.trellisQuantisation=false] - apply trellis quantisation
306
+ * @param {boolean} [options.overshootDeringing=false] - apply overshoot deringing
307
+ * @param {boolean} [options.optimiseScans=false] - optimise progressive scans, forces progressive
308
+ * @param {boolean} [options.optimizeScans=false] - alternative spelling of optimiseScans
309
+ * @param {number} [options.quantisationTable=0] - quantization table to use, integer 0-8
310
+ * @param {number} [options.quantizationTable=0] - alternative spelling of quantisationTable
311
+ * @param {boolean} [options.force=true] - force JPEG output, otherwise attempt to use input format
312
+ * @returns {Sharp}
313
+ * @throws {Error} Invalid options
314
+ */
315
+ function jpeg (options) {
316
+ if (is.object(options)) {
317
+ if (is.defined(options.quality)) {
318
+ if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
319
+ this.options.jpegQuality = options.quality;
320
+ } else {
321
+ throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);
322
+ }
323
+ }
324
+ if (is.defined(options.progressive)) {
325
+ this._setBooleanOption('jpegProgressive', options.progressive);
326
+ }
327
+ if (is.defined(options.chromaSubsampling)) {
328
+ if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) {
329
+ this.options.jpegChromaSubsampling = options.chromaSubsampling;
330
+ } else {
331
+ throw is.invalidParameterError('chromaSubsampling', 'one of: 4:2:0, 4:4:4', options.chromaSubsampling);
332
+ }
333
+ }
334
+ const optimiseCoding = is.bool(options.optimizeCoding) ? options.optimizeCoding : options.optimiseCoding;
335
+ if (is.defined(optimiseCoding)) {
336
+ this._setBooleanOption('jpegOptimiseCoding', optimiseCoding);
337
+ }
338
+ if (is.defined(options.mozjpeg)) {
339
+ if (is.bool(options.mozjpeg)) {
340
+ if (options.mozjpeg) {
341
+ this.options.jpegTrellisQuantisation = true;
342
+ this.options.jpegOvershootDeringing = true;
343
+ this.options.jpegOptimiseScans = true;
344
+ this.options.jpegProgressive = true;
345
+ this.options.jpegQuantisationTable = 3;
346
+ }
347
+ } else {
348
+ throw is.invalidParameterError('mozjpeg', 'boolean', options.mozjpeg);
349
+ }
350
+ }
351
+ const trellisQuantisation = is.bool(options.trellisQuantization) ? options.trellisQuantization : options.trellisQuantisation;
352
+ if (is.defined(trellisQuantisation)) {
353
+ this._setBooleanOption('jpegTrellisQuantisation', trellisQuantisation);
354
+ }
355
+ if (is.defined(options.overshootDeringing)) {
356
+ this._setBooleanOption('jpegOvershootDeringing', options.overshootDeringing);
357
+ }
358
+ const optimiseScans = is.bool(options.optimizeScans) ? options.optimizeScans : options.optimiseScans;
359
+ if (is.defined(optimiseScans)) {
360
+ this._setBooleanOption('jpegOptimiseScans', optimiseScans);
361
+ if (optimiseScans) {
362
+ this.options.jpegProgressive = true;
363
+ }
364
+ }
365
+ const quantisationTable = is.number(options.quantizationTable) ? options.quantizationTable : options.quantisationTable;
366
+ if (is.defined(quantisationTable)) {
367
+ if (is.integer(quantisationTable) && is.inRange(quantisationTable, 0, 8)) {
368
+ this.options.jpegQuantisationTable = quantisationTable;
369
+ } else {
370
+ throw is.invalidParameterError('quantisationTable', 'integer between 0 and 8', quantisationTable);
371
+ }
372
+ }
373
+ }
374
+ return this._updateFormatOut('jpeg', options);
375
+ }
376
+
377
+ /**
378
+ * Use these PNG options for output image.
379
+ *
380
+ * By default, PNG output is full colour at 8 or 16 bits per pixel.
381
+ * Indexed PNG input at 1, 2 or 4 bits per pixel is converted to 8 bits per pixel.
382
+ * Set `palette` to `true` for slower, indexed PNG output.
383
+ *
384
+ * @example
385
+ * // Convert any input to full colour PNG output
386
+ * const data = await sharp(input)
387
+ * .png()
388
+ * .toBuffer();
389
+ *
390
+ * @example
391
+ * // Convert any input to indexed PNG output (slower)
392
+ * const data = await sharp(input)
393
+ * .png({ palette: true })
394
+ * .toBuffer();
395
+ *
396
+ * @param {Object} [options]
397
+ * @param {boolean} [options.progressive=false] - use progressive (interlace) scan
398
+ * @param {number} [options.compressionLevel=6] - zlib compression level, 0 (fastest, largest) to 9 (slowest, smallest)
399
+ * @param {boolean} [options.adaptiveFiltering=false] - use adaptive row filtering
400
+ * @param {boolean} [options.palette=false] - quantise to a palette-based image with alpha transparency support
401
+ * @param {number} [options.quality=100] - use the lowest number of colours needed to achieve given quality, sets `palette` to `true`
402
+ * @param {number} [options.effort=7] - CPU effort, between 1 (fastest) and 10 (slowest), sets `palette` to `true`
403
+ * @param {number} [options.colours=256] - maximum number of palette entries, sets `palette` to `true`
404
+ * @param {number} [options.colors=256] - alternative spelling of `options.colours`, sets `palette` to `true`
405
+ * @param {number} [options.dither=1.0] - level of Floyd-Steinberg error diffusion, sets `palette` to `true`
406
+ * @param {boolean} [options.force=true] - force PNG output, otherwise attempt to use input format
407
+ * @returns {Sharp}
408
+ * @throws {Error} Invalid options
409
+ */
410
+ function png (options) {
411
+ if (is.object(options)) {
412
+ if (is.defined(options.progressive)) {
413
+ this._setBooleanOption('pngProgressive', options.progressive);
414
+ }
415
+ if (is.defined(options.compressionLevel)) {
416
+ if (is.integer(options.compressionLevel) && is.inRange(options.compressionLevel, 0, 9)) {
417
+ this.options.pngCompressionLevel = options.compressionLevel;
418
+ } else {
419
+ throw is.invalidParameterError('compressionLevel', 'integer between 0 and 9', options.compressionLevel);
420
+ }
421
+ }
422
+ if (is.defined(options.adaptiveFiltering)) {
423
+ this._setBooleanOption('pngAdaptiveFiltering', options.adaptiveFiltering);
424
+ }
425
+ const colours = options.colours || options.colors;
426
+ if (is.defined(colours)) {
427
+ if (is.integer(colours) && is.inRange(colours, 2, 256)) {
428
+ this.options.pngBitdepth = bitdepthFromColourCount(colours);
429
+ } else {
430
+ throw is.invalidParameterError('colours', 'integer between 2 and 256', colours);
431
+ }
432
+ }
433
+ if (is.defined(options.palette)) {
434
+ this._setBooleanOption('pngPalette', options.palette);
435
+ } else if ([options.quality, options.effort, options.colours, options.colors, options.dither].some(is.defined)) {
436
+ this._setBooleanOption('pngPalette', true);
437
+ }
438
+ if (this.options.pngPalette) {
439
+ if (is.defined(options.quality)) {
440
+ if (is.integer(options.quality) && is.inRange(options.quality, 0, 100)) {
441
+ this.options.pngQuality = options.quality;
442
+ } else {
443
+ throw is.invalidParameterError('quality', 'integer between 0 and 100', options.quality);
444
+ }
445
+ }
446
+ if (is.defined(options.effort)) {
447
+ if (is.integer(options.effort) && is.inRange(options.effort, 1, 10)) {
448
+ this.options.pngEffort = options.effort;
449
+ } else {
450
+ throw is.invalidParameterError('effort', 'integer between 1 and 10', options.effort);
451
+ }
452
+ }
453
+ if (is.defined(options.dither)) {
454
+ if (is.number(options.dither) && is.inRange(options.dither, 0, 1)) {
455
+ this.options.pngDither = options.dither;
456
+ } else {
457
+ throw is.invalidParameterError('dither', 'number between 0.0 and 1.0', options.dither);
458
+ }
459
+ }
460
+ }
461
+ }
462
+ return this._updateFormatOut('png', options);
463
+ }
464
+
465
+ /**
466
+ * Use these WebP options for output image.
467
+ *
468
+ * @example
469
+ * // Convert any input to lossless WebP output
470
+ * const data = await sharp(input)
471
+ * .webp({ lossless: true })
472
+ * .toBuffer();
473
+ *
474
+ * @example
475
+ * // Optimise the file size of an animated WebP
476
+ * const outputWebp = await sharp(inputWebp, { animated: true })
477
+ * .webp({ effort: 6 })
478
+ * .toBuffer();
479
+ *
480
+ * @param {Object} [options] - output options
481
+ * @param {number} [options.quality=80] - quality, integer 1-100
482
+ * @param {number} [options.alphaQuality=100] - quality of alpha layer, integer 0-100
483
+ * @param {boolean} [options.lossless=false] - use lossless compression mode
484
+ * @param {boolean} [options.nearLossless=false] - use near_lossless compression mode
485
+ * @param {boolean} [options.smartSubsample=false] - use high quality chroma subsampling
486
+ * @param {string} [options.preset='default'] - named preset for preprocessing/filtering, one of: default, photo, picture, drawing, icon, text
487
+ * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 6 (slowest)
488
+ * @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation
489
+ * @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)
490
+ * @param {boolean} [options.minSize=false] - prevent use of animation key frames to minimise file size (slow)
491
+ * @param {boolean} [options.mixed=false] - allow mixture of lossy and lossless animation frames (slow)
492
+ * @param {boolean} [options.force=true] - force WebP output, otherwise attempt to use input format
493
+ * @returns {Sharp}
494
+ * @throws {Error} Invalid options
495
+ */
496
+ function webp (options) {
497
+ if (is.object(options)) {
498
+ if (is.defined(options.quality)) {
499
+ if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
500
+ this.options.webpQuality = options.quality;
501
+ } else {
502
+ throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);
503
+ }
504
+ }
505
+ if (is.defined(options.alphaQuality)) {
506
+ if (is.integer(options.alphaQuality) && is.inRange(options.alphaQuality, 0, 100)) {
507
+ this.options.webpAlphaQuality = options.alphaQuality;
508
+ } else {
509
+ throw is.invalidParameterError('alphaQuality', 'integer between 0 and 100', options.alphaQuality);
510
+ }
511
+ }
512
+ if (is.defined(options.lossless)) {
513
+ this._setBooleanOption('webpLossless', options.lossless);
514
+ }
515
+ if (is.defined(options.nearLossless)) {
516
+ this._setBooleanOption('webpNearLossless', options.nearLossless);
517
+ }
518
+ if (is.defined(options.smartSubsample)) {
519
+ this._setBooleanOption('webpSmartSubsample', options.smartSubsample);
520
+ }
521
+ if (is.defined(options.preset)) {
522
+ if (is.string(options.preset) && is.inArray(options.preset, ['default', 'photo', 'picture', 'drawing', 'icon', 'text'])) {
523
+ this.options.webpPreset = options.preset;
524
+ } else {
525
+ throw is.invalidParameterError('preset', 'one of: default, photo, picture, drawing, icon, text', options.preset);
526
+ }
527
+ }
528
+ if (is.defined(options.effort)) {
529
+ if (is.integer(options.effort) && is.inRange(options.effort, 0, 6)) {
530
+ this.options.webpEffort = options.effort;
531
+ } else {
532
+ throw is.invalidParameterError('effort', 'integer between 0 and 6', options.effort);
533
+ }
534
+ }
535
+ if (is.defined(options.minSize)) {
536
+ this._setBooleanOption('webpMinSize', options.minSize);
537
+ }
538
+ if (is.defined(options.mixed)) {
539
+ this._setBooleanOption('webpMixed', options.mixed);
540
+ }
541
+ }
542
+ trySetAnimationOptions(options, this.options);
543
+ return this._updateFormatOut('webp', options);
544
+ }
545
+
546
+ /**
547
+ * Use these GIF options for the output image.
548
+ *
549
+ * The first entry in the palette is reserved for transparency.
550
+ *
551
+ * The palette of the input image will be re-used if possible.
552
+ *
553
+ * @since 0.30.0
554
+ *
555
+ * @example
556
+ * // Convert PNG to GIF
557
+ * await sharp(pngBuffer)
558
+ * .gif()
559
+ * .toBuffer();
560
+ *
561
+ * @example
562
+ * // Convert animated WebP to animated GIF
563
+ * await sharp('animated.webp', { animated: true })
564
+ * .toFile('animated.gif');
565
+ *
566
+ * @example
567
+ * // Create a 128x128, cropped, non-dithered, animated thumbnail of an animated GIF
568
+ * const out = await sharp('in.gif', { animated: true })
569
+ * .resize({ width: 128, height: 128 })
570
+ * .gif({ dither: 0 })
571
+ * .toBuffer();
572
+ *
573
+ * @example
574
+ * // Lossy file size reduction of animated GIF
575
+ * await sharp('in.gif', { animated: true })
576
+ * .gif({ interFrameMaxError: 8 })
577
+ * .toFile('optim.gif');
578
+ *
579
+ * @param {Object} [options] - output options
580
+ * @param {boolean} [options.reuse=true] - re-use existing palette, otherwise generate new (slow)
581
+ * @param {boolean} [options.progressive=false] - use progressive (interlace) scan
582
+ * @param {number} [options.colours=256] - maximum number of palette entries, including transparency, between 2 and 256
583
+ * @param {number} [options.colors=256] - alternative spelling of `options.colours`
584
+ * @param {number} [options.effort=7] - CPU effort, between 1 (fastest) and 10 (slowest)
585
+ * @param {number} [options.dither=1.0] - level of Floyd-Steinberg error diffusion, between 0 (least) and 1 (most)
586
+ * @param {number} [options.interFrameMaxError=0] - maximum inter-frame error for transparency, between 0 (lossless) and 32
587
+ * @param {number} [options.interPaletteMaxError=3] - maximum inter-palette error for palette reuse, between 0 and 256
588
+ * @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation
589
+ * @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)
590
+ * @param {boolean} [options.force=true] - force GIF output, otherwise attempt to use input format
591
+ * @returns {Sharp}
592
+ * @throws {Error} Invalid options
593
+ */
594
+ function gif (options) {
595
+ if (is.object(options)) {
596
+ if (is.defined(options.reuse)) {
597
+ this._setBooleanOption('gifReuse', options.reuse);
598
+ }
599
+ if (is.defined(options.progressive)) {
600
+ this._setBooleanOption('gifProgressive', options.progressive);
601
+ }
602
+ const colours = options.colours || options.colors;
603
+ if (is.defined(colours)) {
604
+ if (is.integer(colours) && is.inRange(colours, 2, 256)) {
605
+ this.options.gifBitdepth = bitdepthFromColourCount(colours);
606
+ } else {
607
+ throw is.invalidParameterError('colours', 'integer between 2 and 256', colours);
608
+ }
609
+ }
610
+ if (is.defined(options.effort)) {
611
+ if (is.number(options.effort) && is.inRange(options.effort, 1, 10)) {
612
+ this.options.gifEffort = options.effort;
613
+ } else {
614
+ throw is.invalidParameterError('effort', 'integer between 1 and 10', options.effort);
615
+ }
616
+ }
617
+ if (is.defined(options.dither)) {
618
+ if (is.number(options.dither) && is.inRange(options.dither, 0, 1)) {
619
+ this.options.gifDither = options.dither;
620
+ } else {
621
+ throw is.invalidParameterError('dither', 'number between 0.0 and 1.0', options.dither);
622
+ }
623
+ }
624
+ if (is.defined(options.interFrameMaxError)) {
625
+ if (is.number(options.interFrameMaxError) && is.inRange(options.interFrameMaxError, 0, 32)) {
626
+ this.options.gifInterFrameMaxError = options.interFrameMaxError;
627
+ } else {
628
+ throw is.invalidParameterError('interFrameMaxError', 'number between 0.0 and 32.0', options.interFrameMaxError);
629
+ }
630
+ }
631
+ if (is.defined(options.interPaletteMaxError)) {
632
+ if (is.number(options.interPaletteMaxError) && is.inRange(options.interPaletteMaxError, 0, 256)) {
633
+ this.options.gifInterPaletteMaxError = options.interPaletteMaxError;
634
+ } else {
635
+ throw is.invalidParameterError('interPaletteMaxError', 'number between 0.0 and 256.0', options.interPaletteMaxError);
636
+ }
637
+ }
638
+ }
639
+ trySetAnimationOptions(options, this.options);
640
+ return this._updateFormatOut('gif', options);
641
+ }
642
+
643
+ /* istanbul ignore next */
644
+ /**
645
+ * Use these JP2 options for output image.
646
+ *
647
+ * Requires libvips compiled with support for OpenJPEG.
648
+ * The prebuilt binaries do not include this - see
649
+ * {@link https://sharp.pixelplumbing.com/install#custom-libvips installing a custom libvips}.
650
+ *
651
+ * @example
652
+ * // Convert any input to lossless JP2 output
653
+ * const data = await sharp(input)
654
+ * .jp2({ lossless: true })
655
+ * .toBuffer();
656
+ *
657
+ * @example
658
+ * // Convert any input to very high quality JP2 output
659
+ * const data = await sharp(input)
660
+ * .jp2({
661
+ * quality: 100,
662
+ * chromaSubsampling: '4:4:4'
663
+ * })
664
+ * .toBuffer();
665
+ *
666
+ * @since 0.29.1
667
+ *
668
+ * @param {Object} [options] - output options
669
+ * @param {number} [options.quality=80] - quality, integer 1-100
670
+ * @param {boolean} [options.lossless=false] - use lossless compression mode
671
+ * @param {number} [options.tileWidth=512] - horizontal tile size
672
+ * @param {number} [options.tileHeight=512] - vertical tile size
673
+ * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
674
+ * @returns {Sharp}
675
+ * @throws {Error} Invalid options
676
+ */
677
+ function jp2 (options) {
678
+ if (!this.constructor.format.jp2k.output.buffer) {
679
+ throw errJp2Save();
680
+ }
681
+ if (is.object(options)) {
682
+ if (is.defined(options.quality)) {
683
+ if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
684
+ this.options.jp2Quality = options.quality;
685
+ } else {
686
+ throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);
687
+ }
688
+ }
689
+ if (is.defined(options.lossless)) {
690
+ if (is.bool(options.lossless)) {
691
+ this.options.jp2Lossless = options.lossless;
692
+ } else {
693
+ throw is.invalidParameterError('lossless', 'boolean', options.lossless);
694
+ }
695
+ }
696
+ if (is.defined(options.tileWidth)) {
697
+ if (is.integer(options.tileWidth) && is.inRange(options.tileWidth, 1, 32768)) {
698
+ this.options.jp2TileWidth = options.tileWidth;
699
+ } else {
700
+ throw is.invalidParameterError('tileWidth', 'integer between 1 and 32768', options.tileWidth);
701
+ }
702
+ }
703
+ if (is.defined(options.tileHeight)) {
704
+ if (is.integer(options.tileHeight) && is.inRange(options.tileHeight, 1, 32768)) {
705
+ this.options.jp2TileHeight = options.tileHeight;
706
+ } else {
707
+ throw is.invalidParameterError('tileHeight', 'integer between 1 and 32768', options.tileHeight);
708
+ }
709
+ }
710
+ if (is.defined(options.chromaSubsampling)) {
711
+ if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) {
712
+ this.options.jp2ChromaSubsampling = options.chromaSubsampling;
713
+ } else {
714
+ throw is.invalidParameterError('chromaSubsampling', 'one of: 4:2:0, 4:4:4', options.chromaSubsampling);
715
+ }
716
+ }
717
+ }
718
+ return this._updateFormatOut('jp2', options);
719
+ }
720
+
721
+ /**
722
+ * Set animation options if available.
723
+ * @private
724
+ *
725
+ * @param {Object} [source] - output options
726
+ * @param {number} [source.loop=0] - number of animation iterations, use 0 for infinite animation
727
+ * @param {number[]} [source.delay] - list of delays between animation frames (in milliseconds)
728
+ * @param {Object} [target] - target object for valid options
729
+ * @throws {Error} Invalid options
730
+ */
731
+ function trySetAnimationOptions (source, target) {
732
+ if (is.object(source) && is.defined(source.loop)) {
733
+ if (is.integer(source.loop) && is.inRange(source.loop, 0, 65535)) {
734
+ target.loop = source.loop;
735
+ } else {
736
+ throw is.invalidParameterError('loop', 'integer between 0 and 65535', source.loop);
737
+ }
738
+ }
739
+ if (is.object(source) && is.defined(source.delay)) {
740
+ // We allow singular values as well
741
+ if (is.integer(source.delay) && is.inRange(source.delay, 0, 65535)) {
742
+ target.delay = [source.delay];
743
+ } else if (
744
+ Array.isArray(source.delay) &&
745
+ source.delay.every(is.integer) &&
746
+ source.delay.every(v => is.inRange(v, 0, 65535))) {
747
+ target.delay = source.delay;
748
+ } else {
749
+ throw is.invalidParameterError('delay', 'integer or an array of integers between 0 and 65535', source.delay);
750
+ }
751
+ }
752
+ }
753
+
754
+ /**
755
+ * Use these TIFF options for output image.
756
+ *
757
+ * The `density` can be set in pixels/inch via {@link #withmetadata|withMetadata}
758
+ * instead of providing `xres` and `yres` in pixels/mm.
759
+ *
760
+ * @example
761
+ * // Convert SVG input to LZW-compressed, 1 bit per pixel TIFF output
762
+ * sharp('input.svg')
763
+ * .tiff({
764
+ * compression: 'lzw',
765
+ * bitdepth: 1
766
+ * })
767
+ * .toFile('1-bpp-output.tiff')
768
+ * .then(info => { ... });
769
+ *
770
+ * @param {Object} [options] - output options
771
+ * @param {number} [options.quality=80] - quality, integer 1-100
772
+ * @param {boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format
773
+ * @param {string} [options.compression='jpeg'] - compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k
774
+ * @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float
775
+ * @param {boolean} [options.pyramid=false] - write an image pyramid
776
+ * @param {boolean} [options.tile=false] - write a tiled tiff
777
+ * @param {number} [options.tileWidth=256] - horizontal tile size
778
+ * @param {number} [options.tileHeight=256] - vertical tile size
779
+ * @param {number} [options.xres=1.0] - horizontal resolution in pixels/mm
780
+ * @param {number} [options.yres=1.0] - vertical resolution in pixels/mm
781
+ * @param {string} [options.resolutionUnit='inch'] - resolution unit options: inch, cm
782
+ * @param {number} [options.bitdepth=8] - reduce bitdepth to 1, 2 or 4 bit
783
+ * @returns {Sharp}
784
+ * @throws {Error} Invalid options
785
+ */
786
+ function tiff (options) {
787
+ if (is.object(options)) {
788
+ if (is.defined(options.quality)) {
789
+ if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
790
+ this.options.tiffQuality = options.quality;
791
+ } else {
792
+ throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);
793
+ }
794
+ }
795
+ if (is.defined(options.bitdepth)) {
796
+ if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4, 8])) {
797
+ this.options.tiffBitdepth = options.bitdepth;
798
+ } else {
799
+ throw is.invalidParameterError('bitdepth', '1, 2, 4 or 8', options.bitdepth);
800
+ }
801
+ }
802
+ // tiling
803
+ if (is.defined(options.tile)) {
804
+ this._setBooleanOption('tiffTile', options.tile);
805
+ }
806
+ if (is.defined(options.tileWidth)) {
807
+ if (is.integer(options.tileWidth) && options.tileWidth > 0) {
808
+ this.options.tiffTileWidth = options.tileWidth;
809
+ } else {
810
+ throw is.invalidParameterError('tileWidth', 'integer greater than zero', options.tileWidth);
811
+ }
812
+ }
813
+ if (is.defined(options.tileHeight)) {
814
+ if (is.integer(options.tileHeight) && options.tileHeight > 0) {
815
+ this.options.tiffTileHeight = options.tileHeight;
816
+ } else {
817
+ throw is.invalidParameterError('tileHeight', 'integer greater than zero', options.tileHeight);
818
+ }
819
+ }
820
+ // pyramid
821
+ if (is.defined(options.pyramid)) {
822
+ this._setBooleanOption('tiffPyramid', options.pyramid);
823
+ }
824
+ // resolution
825
+ if (is.defined(options.xres)) {
826
+ if (is.number(options.xres) && options.xres > 0) {
827
+ this.options.tiffXres = options.xres;
828
+ } else {
829
+ throw is.invalidParameterError('xres', 'number greater than zero', options.xres);
830
+ }
831
+ }
832
+ if (is.defined(options.yres)) {
833
+ if (is.number(options.yres) && options.yres > 0) {
834
+ this.options.tiffYres = options.yres;
835
+ } else {
836
+ throw is.invalidParameterError('yres', 'number greater than zero', options.yres);
837
+ }
838
+ }
839
+ // compression
840
+ if (is.defined(options.compression)) {
841
+ if (is.string(options.compression) && is.inArray(options.compression, ['none', 'jpeg', 'deflate', 'packbits', 'ccittfax4', 'lzw', 'webp', 'zstd', 'jp2k'])) {
842
+ this.options.tiffCompression = options.compression;
843
+ } else {
844
+ throw is.invalidParameterError('compression', 'one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k', options.compression);
845
+ }
846
+ }
847
+ // predictor
848
+ if (is.defined(options.predictor)) {
849
+ if (is.string(options.predictor) && is.inArray(options.predictor, ['none', 'horizontal', 'float'])) {
850
+ this.options.tiffPredictor = options.predictor;
851
+ } else {
852
+ throw is.invalidParameterError('predictor', 'one of: none, horizontal, float', options.predictor);
853
+ }
854
+ }
855
+ // resolutionUnit
856
+ if (is.defined(options.resolutionUnit)) {
857
+ if (is.string(options.resolutionUnit) && is.inArray(options.resolutionUnit, ['inch', 'cm'])) {
858
+ this.options.tiffResolutionUnit = options.resolutionUnit;
859
+ } else {
860
+ throw is.invalidParameterError('resolutionUnit', 'one of: inch, cm', options.resolutionUnit);
861
+ }
862
+ }
863
+ }
864
+ return this._updateFormatOut('tiff', options);
865
+ }
866
+
867
+ /**
868
+ * Use these AVIF options for output image.
869
+ *
870
+ * Whilst it is possible to create AVIF images smaller than 16x16 pixels,
871
+ * most web browsers do not display these properly.
872
+ *
873
+ * AVIF image sequences are not supported.
874
+ *
875
+ * @example
876
+ * const data = await sharp(input)
877
+ * .avif({ effort: 2 })
878
+ * .toBuffer();
879
+ *
880
+ * @example
881
+ * const data = await sharp(input)
882
+ * .avif({ lossless: true })
883
+ * .toBuffer();
884
+ *
885
+ * @since 0.27.0
886
+ *
887
+ * @param {Object} [options] - output options
888
+ * @param {number} [options.quality=50] - quality, integer 1-100
889
+ * @param {boolean} [options.lossless=false] - use lossless compression
890
+ * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
891
+ * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
892
+ * @returns {Sharp}
893
+ * @throws {Error} Invalid options
894
+ */
895
+ function avif (options) {
896
+ return this.heif({ ...options, compression: 'av1' });
897
+ }
898
+
899
+ /**
900
+ * Use these HEIF options for output image.
901
+ *
902
+ * Support for patent-encumbered HEIC images using `hevc` compression requires the use of a
903
+ * globally-installed libvips compiled with support for libheif, libde265 and x265.
904
+ *
905
+ * @example
906
+ * const data = await sharp(input)
907
+ * .heif({ compression: 'hevc' })
908
+ * .toBuffer();
909
+ *
910
+ * @since 0.23.0
911
+ *
912
+ * @param {Object} [options] - output options
913
+ * @param {number} [options.quality=50] - quality, integer 1-100
914
+ * @param {string} [options.compression='av1'] - compression format: av1, hevc
915
+ * @param {boolean} [options.lossless=false] - use lossless compression
916
+ * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
917
+ * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
918
+ * @returns {Sharp}
919
+ * @throws {Error} Invalid options
920
+ */
921
+ function heif (options) {
922
+ if (is.object(options)) {
923
+ if (is.defined(options.quality)) {
924
+ if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
925
+ this.options.heifQuality = options.quality;
926
+ } else {
927
+ throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);
928
+ }
929
+ }
930
+ if (is.defined(options.lossless)) {
931
+ if (is.bool(options.lossless)) {
932
+ this.options.heifLossless = options.lossless;
933
+ } else {
934
+ throw is.invalidParameterError('lossless', 'boolean', options.lossless);
935
+ }
936
+ }
937
+ if (is.defined(options.compression)) {
938
+ if (is.string(options.compression) && is.inArray(options.compression, ['av1', 'hevc'])) {
939
+ this.options.heifCompression = options.compression;
940
+ } else {
941
+ throw is.invalidParameterError('compression', 'one of: av1, hevc', options.compression);
942
+ }
943
+ }
944
+ if (is.defined(options.effort)) {
945
+ if (is.integer(options.effort) && is.inRange(options.effort, 0, 9)) {
946
+ this.options.heifEffort = options.effort;
947
+ } else {
948
+ throw is.invalidParameterError('effort', 'integer between 0 and 9', options.effort);
949
+ }
950
+ }
951
+ if (is.defined(options.chromaSubsampling)) {
952
+ if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) {
953
+ this.options.heifChromaSubsampling = options.chromaSubsampling;
954
+ } else {
955
+ throw is.invalidParameterError('chromaSubsampling', 'one of: 4:2:0, 4:4:4', options.chromaSubsampling);
956
+ }
957
+ }
958
+ }
959
+ return this._updateFormatOut('heif', options);
960
+ }
961
+
962
+ /**
963
+ * Use these JPEG-XL (JXL) options for output image.
964
+ *
965
+ * This feature is experimental, please do not use in production systems.
966
+ *
967
+ * Requires libvips compiled with support for libjxl.
968
+ * The prebuilt binaries do not include this - see
969
+ * {@link https://sharp.pixelplumbing.com/install#custom-libvips installing a custom libvips}.
970
+ *
971
+ * Image metadata (EXIF, XMP) is unsupported.
972
+ *
973
+ * @since 0.31.3
974
+ *
975
+ * @param {Object} [options] - output options
976
+ * @param {number} [options.distance=1.0] - maximum encoding error, between 0 (highest quality) and 15 (lowest quality)
977
+ * @param {number} [options.quality] - calculate `distance` based on JPEG-like quality, between 1 and 100, overrides distance if specified
978
+ * @param {number} [options.decodingTier=0] - target decode speed tier, between 0 (highest quality) and 4 (lowest quality)
979
+ * @param {boolean} [options.lossless=false] - use lossless compression
980
+ * @param {number} [options.effort=7] - CPU effort, between 3 (fastest) and 9 (slowest)
981
+ * @returns {Sharp}
982
+ * @throws {Error} Invalid options
983
+ */
984
+ function jxl (options) {
985
+ if (is.object(options)) {
986
+ if (is.defined(options.quality)) {
987
+ if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
988
+ // https://github.com/libjxl/libjxl/blob/0aeea7f180bafd6893c1db8072dcb67d2aa5b03d/tools/cjxl_main.cc#L640-L644
989
+ this.options.jxlDistance = options.quality >= 30
990
+ ? 0.1 + (100 - options.quality) * 0.09
991
+ : 53 / 3000 * options.quality * options.quality - 23 / 20 * options.quality + 25;
992
+ } else {
993
+ throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);
994
+ }
995
+ } else if (is.defined(options.distance)) {
996
+ if (is.number(options.distance) && is.inRange(options.distance, 0, 15)) {
997
+ this.options.jxlDistance = options.distance;
998
+ } else {
999
+ throw is.invalidParameterError('distance', 'number between 0.0 and 15.0', options.distance);
1000
+ }
1001
+ }
1002
+ if (is.defined(options.decodingTier)) {
1003
+ if (is.integer(options.decodingTier) && is.inRange(options.decodingTier, 0, 4)) {
1004
+ this.options.jxlDecodingTier = options.decodingTier;
1005
+ } else {
1006
+ throw is.invalidParameterError('decodingTier', 'integer between 0 and 4', options.decodingTier);
1007
+ }
1008
+ }
1009
+ if (is.defined(options.lossless)) {
1010
+ if (is.bool(options.lossless)) {
1011
+ this.options.jxlLossless = options.lossless;
1012
+ } else {
1013
+ throw is.invalidParameterError('lossless', 'boolean', options.lossless);
1014
+ }
1015
+ }
1016
+ if (is.defined(options.effort)) {
1017
+ if (is.integer(options.effort) && is.inRange(options.effort, 3, 9)) {
1018
+ this.options.jxlEffort = options.effort;
1019
+ } else {
1020
+ throw is.invalidParameterError('effort', 'integer between 3 and 9', options.effort);
1021
+ }
1022
+ }
1023
+ }
1024
+ return this._updateFormatOut('jxl', options);
1025
+ }
1026
+
1027
+ /**
1028
+ * Force output to be raw, uncompressed pixel data.
1029
+ * Pixel ordering is left-to-right, top-to-bottom, without padding.
1030
+ * Channel ordering will be RGB or RGBA for non-greyscale colourspaces.
1031
+ *
1032
+ * @example
1033
+ * // Extract raw, unsigned 8-bit RGB pixel data from JPEG input
1034
+ * const { data, info } = await sharp('input.jpg')
1035
+ * .raw()
1036
+ * .toBuffer({ resolveWithObject: true });
1037
+ *
1038
+ * @example
1039
+ * // Extract alpha channel as raw, unsigned 16-bit pixel data from PNG input
1040
+ * const data = await sharp('input.png')
1041
+ * .ensureAlpha()
1042
+ * .extractChannel(3)
1043
+ * .toColourspace('b-w')
1044
+ * .raw({ depth: 'ushort' })
1045
+ * .toBuffer();
1046
+ *
1047
+ * @param {Object} [options] - output options
1048
+ * @param {string} [options.depth='uchar'] - bit depth, one of: char, uchar (default), short, ushort, int, uint, float, complex, double, dpcomplex
1049
+ * @returns {Sharp}
1050
+ * @throws {Error} Invalid options
1051
+ */
1052
+ function raw (options) {
1053
+ if (is.object(options)) {
1054
+ if (is.defined(options.depth)) {
1055
+ if (is.string(options.depth) && is.inArray(options.depth,
1056
+ ['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'float', 'complex', 'double', 'dpcomplex']
1057
+ )) {
1058
+ this.options.rawDepth = options.depth;
1059
+ } else {
1060
+ throw is.invalidParameterError('depth', 'one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex', options.depth);
1061
+ }
1062
+ }
1063
+ }
1064
+ return this._updateFormatOut('raw');
1065
+ }
1066
+
1067
+ /**
1068
+ * Use tile-based deep zoom (image pyramid) output.
1069
+ *
1070
+ * Set the format and options for tile images via the `toFormat`, `jpeg`, `png` or `webp` functions.
1071
+ * Use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format.
1072
+ *
1073
+ * The container will be set to `zip` when the output is a Buffer or Stream, otherwise it will default to `fs`.
1074
+ *
1075
+ * Requires libvips compiled with support for libgsf.
1076
+ * The prebuilt binaries do not include this - see
1077
+ * {@link https://sharp.pixelplumbing.com/install#custom-libvips installing a custom libvips}.
1078
+ *
1079
+ * @example
1080
+ * sharp('input.tiff')
1081
+ * .png()
1082
+ * .tile({
1083
+ * size: 512
1084
+ * })
1085
+ * .toFile('output.dz', function(err, info) {
1086
+ * // output.dzi is the Deep Zoom XML definition
1087
+ * // output_files contains 512x512 tiles grouped by zoom level
1088
+ * });
1089
+ *
1090
+ * @example
1091
+ * const zipFileWithTiles = await sharp(input)
1092
+ * .tile({ basename: "tiles" })
1093
+ * .toBuffer();
1094
+ *
1095
+ * @example
1096
+ * const iiififier = sharp().tile({ layout: "iiif" });
1097
+ * readableStream
1098
+ * .pipe(iiififier)
1099
+ * .pipe(writeableStream);
1100
+ *
1101
+ * @param {Object} [options]
1102
+ * @param {number} [options.size=256] tile size in pixels, a value between 1 and 8192.
1103
+ * @param {number} [options.overlap=0] tile overlap in pixels, a value between 0 and 8192.
1104
+ * @param {number} [options.angle=0] tile angle of rotation, must be a multiple of 90.
1105
+ * @param {string|Object} [options.background={r: 255, g: 255, b: 255, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to white without transparency.
1106
+ * @param {string} [options.depth] how deep to make the pyramid, possible values are `onepixel`, `onetile` or `one`, default based on layout.
1107
+ * @param {number} [options.skipBlanks=-1] threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images
1108
+ * @param {string} [options.container='fs'] tile container, with value `fs` (filesystem) or `zip` (compressed file).
1109
+ * @param {string} [options.layout='dz'] filesystem layout, possible values are `dz`, `iiif`, `iiif3`, `zoomify` or `google`.
1110
+ * @param {boolean} [options.centre=false] centre image in tile.
1111
+ * @param {boolean} [options.center=false] alternative spelling of centre.
1112
+ * @param {string} [options.id='https://example.com/iiif'] when `layout` is `iiif`/`iiif3`, sets the `@id`/`id` attribute of `info.json`
1113
+ * @param {string} [options.basename] the name of the directory within the zip file when container is `zip`.
1114
+ * @returns {Sharp}
1115
+ * @throws {Error} Invalid parameters
1116
+ */
1117
+ function tile (options) {
1118
+ if (is.object(options)) {
1119
+ // Size of square tiles, in pixels
1120
+ if (is.defined(options.size)) {
1121
+ if (is.integer(options.size) && is.inRange(options.size, 1, 8192)) {
1122
+ this.options.tileSize = options.size;
1123
+ } else {
1124
+ throw is.invalidParameterError('size', 'integer between 1 and 8192', options.size);
1125
+ }
1126
+ }
1127
+ // Overlap of tiles, in pixels
1128
+ if (is.defined(options.overlap)) {
1129
+ if (is.integer(options.overlap) && is.inRange(options.overlap, 0, 8192)) {
1130
+ if (options.overlap > this.options.tileSize) {
1131
+ throw is.invalidParameterError('overlap', `<= size (${this.options.tileSize})`, options.overlap);
1132
+ }
1133
+ this.options.tileOverlap = options.overlap;
1134
+ } else {
1135
+ throw is.invalidParameterError('overlap', 'integer between 0 and 8192', options.overlap);
1136
+ }
1137
+ }
1138
+ // Container
1139
+ if (is.defined(options.container)) {
1140
+ if (is.string(options.container) && is.inArray(options.container, ['fs', 'zip'])) {
1141
+ this.options.tileContainer = options.container;
1142
+ } else {
1143
+ throw is.invalidParameterError('container', 'one of: fs, zip', options.container);
1144
+ }
1145
+ }
1146
+ // Layout
1147
+ if (is.defined(options.layout)) {
1148
+ if (is.string(options.layout) && is.inArray(options.layout, ['dz', 'google', 'iiif', 'iiif3', 'zoomify'])) {
1149
+ this.options.tileLayout = options.layout;
1150
+ } else {
1151
+ throw is.invalidParameterError('layout', 'one of: dz, google, iiif, iiif3, zoomify', options.layout);
1152
+ }
1153
+ }
1154
+ // Angle of rotation,
1155
+ if (is.defined(options.angle)) {
1156
+ if (is.integer(options.angle) && !(options.angle % 90)) {
1157
+ this.options.tileAngle = options.angle;
1158
+ } else {
1159
+ throw is.invalidParameterError('angle', 'positive/negative multiple of 90', options.angle);
1160
+ }
1161
+ }
1162
+ // Background colour
1163
+ this._setBackgroundColourOption('tileBackground', options.background);
1164
+ // Depth of tiles
1165
+ if (is.defined(options.depth)) {
1166
+ if (is.string(options.depth) && is.inArray(options.depth, ['onepixel', 'onetile', 'one'])) {
1167
+ this.options.tileDepth = options.depth;
1168
+ } else {
1169
+ throw is.invalidParameterError('depth', 'one of: onepixel, onetile, one', options.depth);
1170
+ }
1171
+ }
1172
+ // Threshold to skip blank tiles
1173
+ if (is.defined(options.skipBlanks)) {
1174
+ if (is.integer(options.skipBlanks) && is.inRange(options.skipBlanks, -1, 65535)) {
1175
+ this.options.tileSkipBlanks = options.skipBlanks;
1176
+ } else {
1177
+ throw is.invalidParameterError('skipBlanks', 'integer between -1 and 255/65535', options.skipBlanks);
1178
+ }
1179
+ } else if (is.defined(options.layout) && options.layout === 'google') {
1180
+ this.options.tileSkipBlanks = 5;
1181
+ }
1182
+ // Center image in tile
1183
+ const centre = is.bool(options.center) ? options.center : options.centre;
1184
+ if (is.defined(centre)) {
1185
+ this._setBooleanOption('tileCentre', centre);
1186
+ }
1187
+ // @id attribute for IIIF layout
1188
+ if (is.defined(options.id)) {
1189
+ if (is.string(options.id)) {
1190
+ this.options.tileId = options.id;
1191
+ } else {
1192
+ throw is.invalidParameterError('id', 'string', options.id);
1193
+ }
1194
+ }
1195
+ // Basename for zip container
1196
+ if (is.defined(options.basename)) {
1197
+ if (is.string(options.basename)) {
1198
+ this.options.tileBasename = options.basename;
1199
+ } else {
1200
+ throw is.invalidParameterError('basename', 'string', options.basename);
1201
+ }
1202
+ }
1203
+ }
1204
+ // Format
1205
+ if (is.inArray(this.options.formatOut, ['jpeg', 'png', 'webp'])) {
1206
+ this.options.tileFormat = this.options.formatOut;
1207
+ } else if (this.options.formatOut !== 'input') {
1208
+ throw is.invalidParameterError('format', 'one of: jpeg, png, webp', this.options.formatOut);
1209
+ }
1210
+ return this._updateFormatOut('dz');
1211
+ }
1212
+
1213
+ /**
1214
+ * Set a timeout for processing, in seconds.
1215
+ * Use a value of zero to continue processing indefinitely, the default behaviour.
1216
+ *
1217
+ * The clock starts when libvips opens an input image for processing.
1218
+ * Time spent waiting for a libuv thread to become available is not included.
1219
+ *
1220
+ * @example
1221
+ * // Ensure processing takes no longer than 3 seconds
1222
+ * try {
1223
+ * const data = await sharp(input)
1224
+ * .blur(1000)
1225
+ * .timeout({ seconds: 3 })
1226
+ * .toBuffer();
1227
+ * } catch (err) {
1228
+ * if (err.message.includes('timeout')) { ... }
1229
+ * }
1230
+ *
1231
+ * @since 0.29.2
1232
+ *
1233
+ * @param {Object} options
1234
+ * @param {number} options.seconds - Number of seconds after which processing will be stopped
1235
+ * @returns {Sharp}
1236
+ */
1237
+ function timeout (options) {
1238
+ if (!is.plainObject(options)) {
1239
+ throw is.invalidParameterError('options', 'object', options);
1240
+ }
1241
+ if (is.integer(options.seconds) && is.inRange(options.seconds, 0, 3600)) {
1242
+ this.options.timeoutSeconds = options.seconds;
1243
+ } else {
1244
+ throw is.invalidParameterError('seconds', 'integer between 0 and 3600', options.seconds);
1245
+ }
1246
+ return this;
1247
+ }
1248
+
1249
+ /**
1250
+ * Update the output format unless options.force is false,
1251
+ * in which case revert to input format.
1252
+ * @private
1253
+ * @param {string} formatOut
1254
+ * @param {Object} [options]
1255
+ * @param {boolean} [options.force=true] - force output format, otherwise attempt to use input format
1256
+ * @returns {Sharp}
1257
+ */
1258
+ function _updateFormatOut (formatOut, options) {
1259
+ if (!(is.object(options) && options.force === false)) {
1260
+ this.options.formatOut = formatOut;
1261
+ }
1262
+ return this;
1263
+ }
1264
+
1265
+ /**
1266
+ * Update a boolean attribute of the this.options Object.
1267
+ * @private
1268
+ * @param {string} key
1269
+ * @param {boolean} val
1270
+ * @throws {Error} Invalid key
1271
+ */
1272
+ function _setBooleanOption (key, val) {
1273
+ if (is.bool(val)) {
1274
+ this.options[key] = val;
1275
+ } else {
1276
+ throw is.invalidParameterError(key, 'boolean', val);
1277
+ }
1278
+ }
1279
+
1280
+ /**
1281
+ * Called by a WriteableStream to notify us it is ready for data.
1282
+ * @private
1283
+ */
1284
+ function _read () {
1285
+ /* istanbul ignore else */
1286
+ if (!this.options.streamOut) {
1287
+ this.options.streamOut = true;
1288
+ this._pipeline();
1289
+ }
1290
+ }
1291
+
1292
+ /**
1293
+ * Invoke the C++ image processing pipeline
1294
+ * Supports callback, stream and promise variants
1295
+ * @private
1296
+ */
1297
+ function _pipeline (callback) {
1298
+ if (typeof callback === 'function') {
1299
+ // output=file/buffer
1300
+ if (this._isStreamInput()) {
1301
+ // output=file/buffer, input=stream
1302
+ this.on('finish', () => {
1303
+ this._flattenBufferIn();
1304
+ sharp.pipeline(this.options, callback);
1305
+ });
1306
+ } else {
1307
+ // output=file/buffer, input=file/buffer
1308
+ sharp.pipeline(this.options, callback);
1309
+ }
1310
+ return this;
1311
+ } else if (this.options.streamOut) {
1312
+ // output=stream
1313
+ if (this._isStreamInput()) {
1314
+ // output=stream, input=stream
1315
+ this.once('finish', () => {
1316
+ this._flattenBufferIn();
1317
+ sharp.pipeline(this.options, (err, data, info) => {
1318
+ if (err) {
1319
+ this.emit('error', err);
1320
+ } else {
1321
+ this.emit('info', info);
1322
+ this.push(data);
1323
+ }
1324
+ this.push(null);
1325
+ this.on('end', () => this.emit('close'));
1326
+ });
1327
+ });
1328
+ if (this.streamInFinished) {
1329
+ this.emit('finish');
1330
+ }
1331
+ } else {
1332
+ // output=stream, input=file/buffer
1333
+ sharp.pipeline(this.options, (err, data, info) => {
1334
+ if (err) {
1335
+ this.emit('error', err);
1336
+ } else {
1337
+ this.emit('info', info);
1338
+ this.push(data);
1339
+ }
1340
+ this.push(null);
1341
+ this.on('end', () => this.emit('close'));
1342
+ });
1343
+ }
1344
+ return this;
1345
+ } else {
1346
+ // output=promise
1347
+ if (this._isStreamInput()) {
1348
+ // output=promise, input=stream
1349
+ return new Promise((resolve, reject) => {
1350
+ this.once('finish', () => {
1351
+ this._flattenBufferIn();
1352
+ sharp.pipeline(this.options, (err, data, info) => {
1353
+ if (err) {
1354
+ reject(err);
1355
+ } else {
1356
+ if (this.options.resolveWithObject) {
1357
+ resolve({ data, info });
1358
+ } else {
1359
+ resolve(data);
1360
+ }
1361
+ }
1362
+ });
1363
+ });
1364
+ });
1365
+ } else {
1366
+ // output=promise, input=file/buffer
1367
+ return new Promise((resolve, reject) => {
1368
+ sharp.pipeline(this.options, (err, data, info) => {
1369
+ if (err) {
1370
+ reject(err);
1371
+ } else {
1372
+ if (this.options.resolveWithObject) {
1373
+ resolve({ data: data, info: info });
1374
+ } else {
1375
+ resolve(data);
1376
+ }
1377
+ }
1378
+ });
1379
+ });
1380
+ }
1381
+ }
1382
+ }
1383
+
1384
+ /**
1385
+ * Decorate the Sharp prototype with output-related functions.
1386
+ * @private
1387
+ */
1388
+ module.exports = function (Sharp) {
1389
+ Object.assign(Sharp.prototype, {
1390
+ // Public
1391
+ toFile,
1392
+ toBuffer,
1393
+ withMetadata,
1394
+ toFormat,
1395
+ jpeg,
1396
+ jp2,
1397
+ png,
1398
+ webp,
1399
+ tiff,
1400
+ avif,
1401
+ heif,
1402
+ jxl,
1403
+ gif,
1404
+ raw,
1405
+ tile,
1406
+ timeout,
1407
+ // Private
1408
+ _updateFormatOut,
1409
+ _setBooleanOption,
1410
+ _read,
1411
+ _pipeline
1412
+ });
1413
+ };