@min-pack/sharp-x86-64-v1 0.33.5

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 (109) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +6 -0
  3. package/index.js +1 -0
  4. package/package.json +7 -0
  5. package/pkg/lib/channel.js +174 -0
  6. package/pkg/lib/colour.js +180 -0
  7. package/pkg/lib/composite.js +210 -0
  8. package/pkg/lib/constructor.js +452 -0
  9. package/pkg/lib/index.js +16 -0
  10. package/pkg/lib/input.js +658 -0
  11. package/pkg/lib/is.js +169 -0
  12. package/pkg/lib/libvips.js +203 -0
  13. package/pkg/lib/operation.js +958 -0
  14. package/pkg/lib/output.js +1587 -0
  15. package/pkg/lib/resize.js +587 -0
  16. package/pkg/lib/sharp.js +114 -0
  17. package/pkg/lib/utility.js +296 -0
  18. package/pkg/node_modules/@img/sharp-libvips-linux-x64/lib/index.js +1 -0
  19. package/pkg/node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.42 +0 -0
  20. package/pkg/node_modules/@img/sharp-libvips-linux-x64/package.json +42 -0
  21. package/pkg/node_modules/@img/sharp-libvips-linux-x64/versions.json +30 -0
  22. package/pkg/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/index.js +1 -0
  23. package/pkg/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/libvips-cpp.so.42 +0 -0
  24. package/pkg/node_modules/@img/sharp-libvips-linuxmusl-x64/package.json +42 -0
  25. package/pkg/node_modules/@img/sharp-libvips-linuxmusl-x64/versions.json +30 -0
  26. package/pkg/node_modules/@img/sharp-linux-x64/LICENSE +191 -0
  27. package/pkg/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node +0 -0
  28. package/pkg/node_modules/@img/sharp-linux-x64/package.json +46 -0
  29. package/pkg/node_modules/@img/sharp-linuxmusl-x64/LICENSE +191 -0
  30. package/pkg/node_modules/@img/sharp-linuxmusl-x64/lib/sharp-linuxmusl-x64.node +0 -0
  31. package/pkg/node_modules/@img/sharp-linuxmusl-x64/package.json +46 -0
  32. package/pkg/node_modules/color/LICENSE +21 -0
  33. package/pkg/node_modules/color/index.js +496 -0
  34. package/pkg/node_modules/color/package.json +47 -0
  35. package/pkg/node_modules/color-convert/LICENSE +21 -0
  36. package/pkg/node_modules/color-convert/conversions.js +839 -0
  37. package/pkg/node_modules/color-convert/index.js +81 -0
  38. package/pkg/node_modules/color-convert/package.json +48 -0
  39. package/pkg/node_modules/color-convert/route.js +97 -0
  40. package/pkg/node_modules/color-name/LICENSE +8 -0
  41. package/pkg/node_modules/color-name/index.js +152 -0
  42. package/pkg/node_modules/color-name/package.json +28 -0
  43. package/pkg/node_modules/color-string/LICENSE +21 -0
  44. package/pkg/node_modules/color-string/index.js +242 -0
  45. package/pkg/node_modules/color-string/package.json +39 -0
  46. package/pkg/node_modules/detect-libc/LICENSE +201 -0
  47. package/pkg/node_modules/detect-libc/lib/detect-libc.js +313 -0
  48. package/pkg/node_modules/detect-libc/lib/elf.js +39 -0
  49. package/pkg/node_modules/detect-libc/lib/filesystem.js +51 -0
  50. package/pkg/node_modules/detect-libc/lib/process.js +24 -0
  51. package/pkg/node_modules/detect-libc/package.json +44 -0
  52. package/pkg/node_modules/is-arrayish/LICENSE +21 -0
  53. package/pkg/node_modules/is-arrayish/index.js +9 -0
  54. package/pkg/node_modules/is-arrayish/package.json +45 -0
  55. package/pkg/node_modules/semver/LICENSE +15 -0
  56. package/pkg/node_modules/semver/bin/semver.js +191 -0
  57. package/pkg/node_modules/semver/classes/comparator.js +143 -0
  58. package/pkg/node_modules/semver/classes/index.js +7 -0
  59. package/pkg/node_modules/semver/classes/range.js +557 -0
  60. package/pkg/node_modules/semver/classes/semver.js +333 -0
  61. package/pkg/node_modules/semver/functions/clean.js +8 -0
  62. package/pkg/node_modules/semver/functions/cmp.js +54 -0
  63. package/pkg/node_modules/semver/functions/coerce.js +62 -0
  64. package/pkg/node_modules/semver/functions/compare-build.js +9 -0
  65. package/pkg/node_modules/semver/functions/compare-loose.js +5 -0
  66. package/pkg/node_modules/semver/functions/compare.js +7 -0
  67. package/pkg/node_modules/semver/functions/diff.js +60 -0
  68. package/pkg/node_modules/semver/functions/eq.js +5 -0
  69. package/pkg/node_modules/semver/functions/gt.js +5 -0
  70. package/pkg/node_modules/semver/functions/gte.js +5 -0
  71. package/pkg/node_modules/semver/functions/inc.js +21 -0
  72. package/pkg/node_modules/semver/functions/lt.js +5 -0
  73. package/pkg/node_modules/semver/functions/lte.js +5 -0
  74. package/pkg/node_modules/semver/functions/major.js +5 -0
  75. package/pkg/node_modules/semver/functions/minor.js +5 -0
  76. package/pkg/node_modules/semver/functions/neq.js +5 -0
  77. package/pkg/node_modules/semver/functions/parse.js +18 -0
  78. package/pkg/node_modules/semver/functions/patch.js +5 -0
  79. package/pkg/node_modules/semver/functions/prerelease.js +8 -0
  80. package/pkg/node_modules/semver/functions/rcompare.js +5 -0
  81. package/pkg/node_modules/semver/functions/rsort.js +5 -0
  82. package/pkg/node_modules/semver/functions/satisfies.js +12 -0
  83. package/pkg/node_modules/semver/functions/sort.js +5 -0
  84. package/pkg/node_modules/semver/functions/valid.js +8 -0
  85. package/pkg/node_modules/semver/index.js +91 -0
  86. package/pkg/node_modules/semver/internal/constants.js +37 -0
  87. package/pkg/node_modules/semver/internal/debug.js +11 -0
  88. package/pkg/node_modules/semver/internal/identifiers.js +29 -0
  89. package/pkg/node_modules/semver/internal/lrucache.js +42 -0
  90. package/pkg/node_modules/semver/internal/parse-options.js +17 -0
  91. package/pkg/node_modules/semver/internal/re.js +223 -0
  92. package/pkg/node_modules/semver/package.json +78 -0
  93. package/pkg/node_modules/semver/preload.js +4 -0
  94. package/pkg/node_modules/semver/range.bnf +16 -0
  95. package/pkg/node_modules/semver/ranges/gtr.js +6 -0
  96. package/pkg/node_modules/semver/ranges/intersects.js +9 -0
  97. package/pkg/node_modules/semver/ranges/ltr.js +6 -0
  98. package/pkg/node_modules/semver/ranges/max-satisfying.js +27 -0
  99. package/pkg/node_modules/semver/ranges/min-satisfying.js +26 -0
  100. package/pkg/node_modules/semver/ranges/min-version.js +63 -0
  101. package/pkg/node_modules/semver/ranges/outside.js +82 -0
  102. package/pkg/node_modules/semver/ranges/simplify.js +49 -0
  103. package/pkg/node_modules/semver/ranges/subset.js +249 -0
  104. package/pkg/node_modules/semver/ranges/to-comparators.js +10 -0
  105. package/pkg/node_modules/semver/ranges/valid.js +13 -0
  106. package/pkg/node_modules/simple-swizzle/LICENSE +21 -0
  107. package/pkg/node_modules/simple-swizzle/index.js +29 -0
  108. package/pkg/node_modules/simple-swizzle/package.json +36 -0
  109. package/pkg/package.json +24 -0
@@ -0,0 +1,210 @@
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const is = require('./is');
7
+
8
+ /**
9
+ * Blend modes.
10
+ * @member
11
+ * @private
12
+ */
13
+ const blend = {
14
+ clear: 'clear',
15
+ source: 'source',
16
+ over: 'over',
17
+ in: 'in',
18
+ out: 'out',
19
+ atop: 'atop',
20
+ dest: 'dest',
21
+ 'dest-over': 'dest-over',
22
+ 'dest-in': 'dest-in',
23
+ 'dest-out': 'dest-out',
24
+ 'dest-atop': 'dest-atop',
25
+ xor: 'xor',
26
+ add: 'add',
27
+ saturate: 'saturate',
28
+ multiply: 'multiply',
29
+ screen: 'screen',
30
+ overlay: 'overlay',
31
+ darken: 'darken',
32
+ lighten: 'lighten',
33
+ 'colour-dodge': 'colour-dodge',
34
+ 'color-dodge': 'colour-dodge',
35
+ 'colour-burn': 'colour-burn',
36
+ 'color-burn': 'colour-burn',
37
+ 'hard-light': 'hard-light',
38
+ 'soft-light': 'soft-light',
39
+ difference: 'difference',
40
+ exclusion: 'exclusion'
41
+ };
42
+
43
+ /**
44
+ * Composite image(s) over the processed (resized, extracted etc.) image.
45
+ *
46
+ * The images to composite must be the same size or smaller than the processed image.
47
+ * If both `top` and `left` options are provided, they take precedence over `gravity`.
48
+ *
49
+ * Any resize, rotate or extract operations in the same processing pipeline
50
+ * will always be applied to the input image before composition.
51
+ *
52
+ * The `blend` option can be one of `clear`, `source`, `over`, `in`, `out`, `atop`,
53
+ * `dest`, `dest-over`, `dest-in`, `dest-out`, `dest-atop`,
54
+ * `xor`, `add`, `saturate`, `multiply`, `screen`, `overlay`, `darken`, `lighten`,
55
+ * `colour-dodge`, `color-dodge`, `colour-burn`,`color-burn`,
56
+ * `hard-light`, `soft-light`, `difference`, `exclusion`.
57
+ *
58
+ * More information about blend modes can be found at
59
+ * https://www.libvips.org/API/current/libvips-conversion.html#VipsBlendMode
60
+ * and https://www.cairographics.org/operators/
61
+ *
62
+ * @since 0.22.0
63
+ *
64
+ * @example
65
+ * await sharp(background)
66
+ * .composite([
67
+ * { input: layer1, gravity: 'northwest' },
68
+ * { input: layer2, gravity: 'southeast' },
69
+ * ])
70
+ * .toFile('combined.png');
71
+ *
72
+ * @example
73
+ * const output = await sharp('input.gif', { animated: true })
74
+ * .composite([
75
+ * { input: 'overlay.png', tile: true, blend: 'saturate' }
76
+ * ])
77
+ * .toBuffer();
78
+ *
79
+ * @example
80
+ * sharp('input.png')
81
+ * .rotate(180)
82
+ * .resize(300)
83
+ * .flatten( { background: '#ff6600' } )
84
+ * .composite([{ input: 'overlay.png', gravity: 'southeast' }])
85
+ * .sharpen()
86
+ * .withMetadata()
87
+ * .webp( { quality: 90 } )
88
+ * .toBuffer()
89
+ * .then(function(outputBuffer) {
90
+ * // outputBuffer contains upside down, 300px wide, alpha channel flattened
91
+ * // onto orange background, composited with overlay.png with SE gravity,
92
+ * // sharpened, with metadata, 90% quality WebP image data. Phew!
93
+ * });
94
+ *
95
+ * @param {Object[]} images - Ordered list of images to composite
96
+ * @param {Buffer|String} [images[].input] - Buffer containing image data, String containing the path to an image file, or Create object (see below)
97
+ * @param {Object} [images[].input.create] - describes a blank overlay to be created.
98
+ * @param {Number} [images[].input.create.width]
99
+ * @param {Number} [images[].input.create.height]
100
+ * @param {Number} [images[].input.create.channels] - 3-4
101
+ * @param {String|Object} [images[].input.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
102
+ * @param {Object} [images[].input.text] - describes a new text image to be created.
103
+ * @param {string} [images[].input.text.text] - text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`.
104
+ * @param {string} [images[].input.text.font] - font name to render with.
105
+ * @param {string} [images[].input.text.fontfile] - absolute filesystem path to a font file that can be used by `font`.
106
+ * @param {number} [images[].input.text.width=0] - integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries.
107
+ * @param {number} [images[].input.text.height=0] - integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0.
108
+ * @param {string} [images[].input.text.align='left'] - text alignment (`'left'`, `'centre'`, `'center'`, `'right'`).
109
+ * @param {boolean} [images[].input.text.justify=false] - set this to true to apply justification to the text.
110
+ * @param {number} [images[].input.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.
111
+ * @param {boolean} [images[].input.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for Pango markup features like `<span foreground="red">Red!</span>`.
112
+ * @param {number} [images[].input.text.spacing=0] - text line height in points. Will use the font line height if none is specified.
113
+ * @param {String} [images[].blend='over'] - how to blend this image with the image below.
114
+ * @param {String} [images[].gravity='centre'] - gravity at which to place the overlay.
115
+ * @param {Number} [images[].top] - the pixel offset from the top edge.
116
+ * @param {Number} [images[].left] - the pixel offset from the left edge.
117
+ * @param {Boolean} [images[].tile=false] - set to true to repeat the overlay image across the entire image with the given `gravity`.
118
+ * @param {Boolean} [images[].premultiplied=false] - set to true to avoid premultiplying the image below. Equivalent to the `--premultiplied` vips option.
119
+ * @param {Number} [images[].density=72] - number representing the DPI for vector overlay image.
120
+ * @param {Object} [images[].raw] - describes overlay when using raw pixel data.
121
+ * @param {Number} [images[].raw.width]
122
+ * @param {Number} [images[].raw.height]
123
+ * @param {Number} [images[].raw.channels]
124
+ * @param {boolean} [images[].animated=false] - Set to `true` to read all frames/pages of an animated image.
125
+ * @param {string} [images[].failOn='warning'] - @see {@link /api-constructor#parameters|constructor parameters}
126
+ * @param {number|boolean} [images[].limitInputPixels=268402689] - @see {@link /api-constructor#parameters|constructor parameters}
127
+ * @returns {Sharp}
128
+ * @throws {Error} Invalid parameters
129
+ */
130
+ function composite (images) {
131
+ if (!Array.isArray(images)) {
132
+ throw is.invalidParameterError('images to composite', 'array', images);
133
+ }
134
+ this.options.composite = images.map(image => {
135
+ if (!is.object(image)) {
136
+ throw is.invalidParameterError('image to composite', 'object', image);
137
+ }
138
+ const inputOptions = this._inputOptionsFromObject(image);
139
+ const composite = {
140
+ input: this._createInputDescriptor(image.input, inputOptions, { allowStream: false }),
141
+ blend: 'over',
142
+ tile: false,
143
+ left: 0,
144
+ top: 0,
145
+ hasOffset: false,
146
+ gravity: 0,
147
+ premultiplied: false
148
+ };
149
+ if (is.defined(image.blend)) {
150
+ if (is.string(blend[image.blend])) {
151
+ composite.blend = blend[image.blend];
152
+ } else {
153
+ throw is.invalidParameterError('blend', 'valid blend name', image.blend);
154
+ }
155
+ }
156
+ if (is.defined(image.tile)) {
157
+ if (is.bool(image.tile)) {
158
+ composite.tile = image.tile;
159
+ } else {
160
+ throw is.invalidParameterError('tile', 'boolean', image.tile);
161
+ }
162
+ }
163
+ if (is.defined(image.left)) {
164
+ if (is.integer(image.left)) {
165
+ composite.left = image.left;
166
+ } else {
167
+ throw is.invalidParameterError('left', 'integer', image.left);
168
+ }
169
+ }
170
+ if (is.defined(image.top)) {
171
+ if (is.integer(image.top)) {
172
+ composite.top = image.top;
173
+ } else {
174
+ throw is.invalidParameterError('top', 'integer', image.top);
175
+ }
176
+ }
177
+ if (is.defined(image.top) !== is.defined(image.left)) {
178
+ throw new Error('Expected both left and top to be set');
179
+ } else {
180
+ composite.hasOffset = is.integer(image.top) && is.integer(image.left);
181
+ }
182
+ if (is.defined(image.gravity)) {
183
+ if (is.integer(image.gravity) && is.inRange(image.gravity, 0, 8)) {
184
+ composite.gravity = image.gravity;
185
+ } else if (is.string(image.gravity) && is.integer(this.constructor.gravity[image.gravity])) {
186
+ composite.gravity = this.constructor.gravity[image.gravity];
187
+ } else {
188
+ throw is.invalidParameterError('gravity', 'valid gravity', image.gravity);
189
+ }
190
+ }
191
+ if (is.defined(image.premultiplied)) {
192
+ if (is.bool(image.premultiplied)) {
193
+ composite.premultiplied = image.premultiplied;
194
+ } else {
195
+ throw is.invalidParameterError('premultiplied', 'boolean', image.premultiplied);
196
+ }
197
+ }
198
+ return composite;
199
+ });
200
+ return this;
201
+ }
202
+
203
+ /**
204
+ * Decorate the Sharp prototype with composite-related functions.
205
+ * @private
206
+ */
207
+ module.exports = function (Sharp) {
208
+ Sharp.prototype.composite = composite;
209
+ Sharp.blend = blend;
210
+ };
@@ -0,0 +1,452 @@
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const util = require('node:util');
7
+ const stream = require('node:stream');
8
+ const is = require('./is');
9
+
10
+ require('./sharp');
11
+
12
+ // Use NODE_DEBUG=sharp to enable libvips warnings
13
+ const debuglog = util.debuglog('sharp');
14
+
15
+ /**
16
+ * Constructor factory to create an instance of `sharp`, to which further methods are chained.
17
+ *
18
+ * JPEG, PNG, WebP, GIF, AVIF or TIFF format image data can be streamed out from this object.
19
+ * When using Stream based output, derived attributes are available from the `info` event.
20
+ *
21
+ * Non-critical problems encountered during processing are emitted as `warning` events.
22
+ *
23
+ * Implements the [stream.Duplex](http://nodejs.org/api/stream.html#stream_class_stream_duplex) class.
24
+ *
25
+ * When loading more than one page/frame of an animated image,
26
+ * these are combined as a vertically-stacked "toilet roll" image
27
+ * where the overall height is the `pageHeight` multiplied by the number of `pages`.
28
+ *
29
+ * @constructs Sharp
30
+ *
31
+ * @emits Sharp#info
32
+ * @emits Sharp#warning
33
+ *
34
+ * @example
35
+ * sharp('input.jpg')
36
+ * .resize(300, 200)
37
+ * .toFile('output.jpg', function(err) {
38
+ * // output.jpg is a 300 pixels wide and 200 pixels high image
39
+ * // containing a scaled and cropped version of input.jpg
40
+ * });
41
+ *
42
+ * @example
43
+ * // Read image data from remote URL,
44
+ * // resize to 300 pixels wide,
45
+ * // emit an 'info' event with calculated dimensions
46
+ * // and finally write image data to writableStream
47
+ * const { body } = fetch('https://...');
48
+ * const readableStream = Readable.fromWeb(body);
49
+ * const transformer = sharp()
50
+ * .resize(300)
51
+ * .on('info', ({ height }) => {
52
+ * console.log(`Image height is ${height}`);
53
+ * });
54
+ * readableStream.pipe(transformer).pipe(writableStream);
55
+ *
56
+ * @example
57
+ * // Create a blank 300x200 PNG image of semi-translucent red pixels
58
+ * sharp({
59
+ * create: {
60
+ * width: 300,
61
+ * height: 200,
62
+ * channels: 4,
63
+ * background: { r: 255, g: 0, b: 0, alpha: 0.5 }
64
+ * }
65
+ * })
66
+ * .png()
67
+ * .toBuffer()
68
+ * .then( ... );
69
+ *
70
+ * @example
71
+ * // Convert an animated GIF to an animated WebP
72
+ * await sharp('in.gif', { animated: true }).toFile('out.webp');
73
+ *
74
+ * @example
75
+ * // Read a raw array of pixels and save it to a png
76
+ * const input = Uint8Array.from([255, 255, 255, 0, 0, 0]); // or Uint8ClampedArray
77
+ * const image = sharp(input, {
78
+ * // because the input does not contain its dimensions or how many channels it has
79
+ * // we need to specify it in the constructor options
80
+ * raw: {
81
+ * width: 2,
82
+ * height: 1,
83
+ * channels: 3
84
+ * }
85
+ * });
86
+ * await image.toFile('my-two-pixels.png');
87
+ *
88
+ * @example
89
+ * // Generate RGB Gaussian noise
90
+ * await sharp({
91
+ * create: {
92
+ * width: 300,
93
+ * height: 200,
94
+ * channels: 3,
95
+ * noise: {
96
+ * type: 'gaussian',
97
+ * mean: 128,
98
+ * sigma: 30
99
+ * }
100
+ * }
101
+ * }).toFile('noise.png');
102
+ *
103
+ * @example
104
+ * // Generate an image from text
105
+ * await sharp({
106
+ * text: {
107
+ * text: 'Hello, world!',
108
+ * width: 400, // max width
109
+ * height: 300 // max height
110
+ * }
111
+ * }).toFile('text_bw.png');
112
+ *
113
+ * @example
114
+ * // Generate an rgba image from text using pango markup and font
115
+ * await sharp({
116
+ * text: {
117
+ * text: '<span foreground="red">Red!</span><span background="cyan">blue</span>',
118
+ * font: 'sans',
119
+ * rgba: true,
120
+ * dpi: 300
121
+ * }
122
+ * }).toFile('text_rgba.png');
123
+ *
124
+ * @param {(Buffer|ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array|Float32Array|Float64Array|string)} [input] - if present, can be
125
+ * a Buffer / ArrayBuffer / Uint8Array / Uint8ClampedArray containing JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image data, or
126
+ * a TypedArray containing raw pixel image data, or
127
+ * a String containing the filesystem path to an JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image file.
128
+ * JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.
129
+ * @param {Object} [options] - if present, is an Object with optional attributes.
130
+ * @param {string} [options.failOn='warning'] - When to abort processing of invalid pixel data, one of (in order of sensitivity, least to most): 'none', 'truncated', 'error', 'warning'. Higher levels imply lower levels. Invalid metadata will always abort.
131
+ * @param {number|boolean} [options.limitInputPixels=268402689] - Do not process input images where the number of pixels
132
+ * (width x height) exceeds this limit. Assumes image dimensions contained in the input metadata can be trusted.
133
+ * An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF).
134
+ * @param {boolean} [options.unlimited=false] - Set this to `true` to remove safety features that help prevent memory exhaustion (JPEG, PNG, SVG, HEIF).
135
+ * @param {boolean} [options.sequentialRead=true] - Set this to `false` to use random access rather than sequential read. Some operations will do this automatically.
136
+ * @param {number} [options.density=72] - number representing the DPI for vector images in the range 1 to 100000.
137
+ * @param {number} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.
138
+ * @param {number} [options.pages=1] - Number of pages to extract for multi-page input (GIF, WebP, TIFF), use -1 for all pages.
139
+ * @param {number} [options.page=0] - Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based.
140
+ * @param {number} [options.subifd=-1] - subIFD (Sub Image File Directory) to extract for OME-TIFF, defaults to main image.
141
+ * @param {number} [options.level=0] - level to extract from a multi-level input (OpenSlide), zero based.
142
+ * @param {boolean} [options.animated=false] - Set to `true` to read all frames/pages of an animated image (GIF, WebP, TIFF), equivalent of setting `pages` to `-1`.
143
+ * @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.
144
+ * @param {number} [options.raw.width] - integral number of pixels wide.
145
+ * @param {number} [options.raw.height] - integral number of pixels high.
146
+ * @param {number} [options.raw.channels] - integral number of channels, between 1 and 4.
147
+ * @param {boolean} [options.raw.premultiplied] - specifies that the raw input has already been premultiplied, set to `true`
148
+ * to avoid sharp premultiplying the image. (optional, default `false`)
149
+ * @param {Object} [options.create] - describes a new image to be created.
150
+ * @param {number} [options.create.width] - integral number of pixels wide.
151
+ * @param {number} [options.create.height] - integral number of pixels high.
152
+ * @param {number} [options.create.channels] - integral number of channels, either 3 (RGB) or 4 (RGBA).
153
+ * @param {string|Object} [options.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
154
+ * @param {Object} [options.create.noise] - describes a noise to be created.
155
+ * @param {string} [options.create.noise.type] - type of generated noise, currently only `gaussian` is supported.
156
+ * @param {number} [options.create.noise.mean] - mean of pixels in generated noise.
157
+ * @param {number} [options.create.noise.sigma] - standard deviation of pixels in generated noise.
158
+ * @param {Object} [options.text] - describes a new text image to be created.
159
+ * @param {string} [options.text.text] - text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`.
160
+ * @param {string} [options.text.font] - font name to render with.
161
+ * @param {string} [options.text.fontfile] - absolute filesystem path to a font file that can be used by `font`.
162
+ * @param {number} [options.text.width=0] - Integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries.
163
+ * @param {number} [options.text.height=0] - Maximum integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0.
164
+ * @param {string} [options.text.align='left'] - Alignment style for multi-line text (`'left'`, `'centre'`, `'center'`, `'right'`).
165
+ * @param {boolean} [options.text.justify=false] - set this to true to apply justification to the text.
166
+ * @param {number} [options.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.
167
+ * @param {boolean} [options.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for pango markup features like `<span foreground="red">Red!</span>`.
168
+ * @param {number} [options.text.spacing=0] - text line height in points. Will use the font line height if none is specified.
169
+ * @param {string} [options.text.wrap='word'] - word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none'.
170
+ * @returns {Sharp}
171
+ * @throws {Error} Invalid parameters
172
+ */
173
+ const Sharp = function (input, options) {
174
+ if (arguments.length === 1 && !is.defined(input)) {
175
+ throw new Error('Invalid input');
176
+ }
177
+ if (!(this instanceof Sharp)) {
178
+ return new Sharp(input, options);
179
+ }
180
+ stream.Duplex.call(this);
181
+ this.options = {
182
+ // resize options
183
+ topOffsetPre: -1,
184
+ leftOffsetPre: -1,
185
+ widthPre: -1,
186
+ heightPre: -1,
187
+ topOffsetPost: -1,
188
+ leftOffsetPost: -1,
189
+ widthPost: -1,
190
+ heightPost: -1,
191
+ width: -1,
192
+ height: -1,
193
+ canvas: 'crop',
194
+ position: 0,
195
+ resizeBackground: [0, 0, 0, 255],
196
+ useExifOrientation: false,
197
+ angle: 0,
198
+ rotationAngle: 0,
199
+ rotationBackground: [0, 0, 0, 255],
200
+ rotateBeforePreExtract: false,
201
+ flip: false,
202
+ flop: false,
203
+ extendTop: 0,
204
+ extendBottom: 0,
205
+ extendLeft: 0,
206
+ extendRight: 0,
207
+ extendBackground: [0, 0, 0, 255],
208
+ extendWith: 'background',
209
+ withoutEnlargement: false,
210
+ withoutReduction: false,
211
+ affineMatrix: [],
212
+ affineBackground: [0, 0, 0, 255],
213
+ affineIdx: 0,
214
+ affineIdy: 0,
215
+ affineOdx: 0,
216
+ affineOdy: 0,
217
+ affineInterpolator: this.constructor.interpolators.bilinear,
218
+ kernel: 'lanczos3',
219
+ fastShrinkOnLoad: true,
220
+ // operations
221
+ tint: [-1, 0, 0, 0],
222
+ flatten: false,
223
+ flattenBackground: [0, 0, 0],
224
+ unflatten: false,
225
+ negate: false,
226
+ negateAlpha: true,
227
+ medianSize: 0,
228
+ blurSigma: 0,
229
+ precision: 'integer',
230
+ minAmpl: 0.2,
231
+ sharpenSigma: 0,
232
+ sharpenM1: 1,
233
+ sharpenM2: 2,
234
+ sharpenX1: 2,
235
+ sharpenY2: 10,
236
+ sharpenY3: 20,
237
+ threshold: 0,
238
+ thresholdGrayscale: true,
239
+ trimBackground: [],
240
+ trimThreshold: -1,
241
+ trimLineArt: false,
242
+ gamma: 0,
243
+ gammaOut: 0,
244
+ greyscale: false,
245
+ normalise: false,
246
+ normaliseLower: 1,
247
+ normaliseUpper: 99,
248
+ claheWidth: 0,
249
+ claheHeight: 0,
250
+ claheMaxSlope: 3,
251
+ brightness: 1,
252
+ saturation: 1,
253
+ hue: 0,
254
+ lightness: 0,
255
+ booleanBufferIn: null,
256
+ booleanFileIn: '',
257
+ joinChannelIn: [],
258
+ extractChannel: -1,
259
+ removeAlpha: false,
260
+ ensureAlpha: -1,
261
+ colourspace: 'srgb',
262
+ colourspacePipeline: 'last',
263
+ composite: [],
264
+ // output
265
+ fileOut: '',
266
+ formatOut: 'input',
267
+ streamOut: false,
268
+ keepMetadata: 0,
269
+ withMetadataOrientation: -1,
270
+ withMetadataDensity: 0,
271
+ withIccProfile: '',
272
+ withExif: {},
273
+ withExifMerge: true,
274
+ resolveWithObject: false,
275
+ // output format
276
+ jpegQuality: 80,
277
+ jpegProgressive: false,
278
+ jpegChromaSubsampling: '4:2:0',
279
+ jpegTrellisQuantisation: false,
280
+ jpegOvershootDeringing: false,
281
+ jpegOptimiseScans: false,
282
+ jpegOptimiseCoding: true,
283
+ jpegQuantisationTable: 0,
284
+ pngProgressive: false,
285
+ pngCompressionLevel: 6,
286
+ pngAdaptiveFiltering: false,
287
+ pngPalette: false,
288
+ pngQuality: 100,
289
+ pngEffort: 7,
290
+ pngBitdepth: 8,
291
+ pngDither: 1,
292
+ jp2Quality: 80,
293
+ jp2TileHeight: 512,
294
+ jp2TileWidth: 512,
295
+ jp2Lossless: false,
296
+ jp2ChromaSubsampling: '4:4:4',
297
+ webpQuality: 80,
298
+ webpAlphaQuality: 100,
299
+ webpLossless: false,
300
+ webpNearLossless: false,
301
+ webpSmartSubsample: false,
302
+ webpPreset: 'default',
303
+ webpEffort: 4,
304
+ webpMinSize: false,
305
+ webpMixed: false,
306
+ gifBitdepth: 8,
307
+ gifEffort: 7,
308
+ gifDither: 1,
309
+ gifInterFrameMaxError: 0,
310
+ gifInterPaletteMaxError: 3,
311
+ gifReuse: true,
312
+ gifProgressive: false,
313
+ tiffQuality: 80,
314
+ tiffCompression: 'jpeg',
315
+ tiffPredictor: 'horizontal',
316
+ tiffPyramid: false,
317
+ tiffMiniswhite: false,
318
+ tiffBitdepth: 8,
319
+ tiffTile: false,
320
+ tiffTileHeight: 256,
321
+ tiffTileWidth: 256,
322
+ tiffXres: 1.0,
323
+ tiffYres: 1.0,
324
+ tiffResolutionUnit: 'inch',
325
+ heifQuality: 50,
326
+ heifLossless: false,
327
+ heifCompression: 'av1',
328
+ heifEffort: 4,
329
+ heifChromaSubsampling: '4:4:4',
330
+ heifBitdepth: 8,
331
+ jxlDistance: 1,
332
+ jxlDecodingTier: 0,
333
+ jxlEffort: 7,
334
+ jxlLossless: false,
335
+ rawDepth: 'uchar',
336
+ tileSize: 256,
337
+ tileOverlap: 0,
338
+ tileContainer: 'fs',
339
+ tileLayout: 'dz',
340
+ tileFormat: 'last',
341
+ tileDepth: 'last',
342
+ tileAngle: 0,
343
+ tileSkipBlanks: -1,
344
+ tileBackground: [255, 255, 255, 255],
345
+ tileCentre: false,
346
+ tileId: 'https://example.com/iiif',
347
+ tileBasename: '',
348
+ timeoutSeconds: 0,
349
+ linearA: [],
350
+ linearB: [],
351
+ // Function to notify of libvips warnings
352
+ debuglog: warning => {
353
+ this.emit('warning', warning);
354
+ debuglog(warning);
355
+ },
356
+ // Function to notify of queue length changes
357
+ queueListener: function (queueLength) {
358
+ Sharp.queue.emit('change', queueLength);
359
+ }
360
+ };
361
+ this.options.input = this._createInputDescriptor(input, options, { allowStream: true });
362
+ return this;
363
+ };
364
+ Object.setPrototypeOf(Sharp.prototype, stream.Duplex.prototype);
365
+ Object.setPrototypeOf(Sharp, stream.Duplex);
366
+
367
+ /**
368
+ * Take a "snapshot" of the Sharp instance, returning a new instance.
369
+ * Cloned instances inherit the input of their parent instance.
370
+ * This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream.
371
+ *
372
+ * @example
373
+ * const pipeline = sharp().rotate();
374
+ * pipeline.clone().resize(800, 600).pipe(firstWritableStream);
375
+ * pipeline.clone().extract({ left: 20, top: 20, width: 100, height: 100 }).pipe(secondWritableStream);
376
+ * readableStream.pipe(pipeline);
377
+ * // firstWritableStream receives auto-rotated, resized readableStream
378
+ * // secondWritableStream receives auto-rotated, extracted region of readableStream
379
+ *
380
+ * @example
381
+ * // Create a pipeline that will download an image, resize it and format it to different files
382
+ * // Using Promises to know when the pipeline is complete
383
+ * const fs = require("fs");
384
+ * const got = require("got");
385
+ * const sharpStream = sharp({ failOn: 'none' });
386
+ *
387
+ * const promises = [];
388
+ *
389
+ * promises.push(
390
+ * sharpStream
391
+ * .clone()
392
+ * .jpeg({ quality: 100 })
393
+ * .toFile("originalFile.jpg")
394
+ * );
395
+ *
396
+ * promises.push(
397
+ * sharpStream
398
+ * .clone()
399
+ * .resize({ width: 500 })
400
+ * .jpeg({ quality: 80 })
401
+ * .toFile("optimized-500.jpg")
402
+ * );
403
+ *
404
+ * promises.push(
405
+ * sharpStream
406
+ * .clone()
407
+ * .resize({ width: 500 })
408
+ * .webp({ quality: 80 })
409
+ * .toFile("optimized-500.webp")
410
+ * );
411
+ *
412
+ * // https://github.com/sindresorhus/got/blob/main/documentation/3-streams.md
413
+ * got.stream("https://www.example.com/some-file.jpg").pipe(sharpStream);
414
+ *
415
+ * Promise.all(promises)
416
+ * .then(res => { console.log("Done!", res); })
417
+ * .catch(err => {
418
+ * console.error("Error processing files, let's clean it up", err);
419
+ * try {
420
+ * fs.unlinkSync("originalFile.jpg");
421
+ * fs.unlinkSync("optimized-500.jpg");
422
+ * fs.unlinkSync("optimized-500.webp");
423
+ * } catch (e) {}
424
+ * });
425
+ *
426
+ * @returns {Sharp}
427
+ */
428
+ function clone () {
429
+ // Clone existing options
430
+ const clone = this.constructor.call();
431
+ const { debuglog, queueListener, ...options } = this.options;
432
+ clone.options = structuredClone(options);
433
+ clone.options.debuglog = debuglog;
434
+ clone.options.queueListener = queueListener;
435
+ // Pass 'finish' event to clone for Stream-based input
436
+ if (this._isStreamInput()) {
437
+ this.on('finish', () => {
438
+ // Clone inherits input data
439
+ this._flattenBufferIn();
440
+ clone.options.input.buffer = this.options.input.buffer;
441
+ clone.emit('finish');
442
+ });
443
+ }
444
+ return clone;
445
+ }
446
+ Object.assign(Sharp.prototype, { clone });
447
+
448
+ /**
449
+ * Export constructor.
450
+ * @private
451
+ */
452
+ module.exports = Sharp;
@@ -0,0 +1,16 @@
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const Sharp = require('./constructor');
7
+ require('./input')(Sharp);
8
+ require('./resize')(Sharp);
9
+ require('./composite')(Sharp);
10
+ require('./operation')(Sharp);
11
+ require('./colour')(Sharp);
12
+ require('./channel')(Sharp);
13
+ require('./output')(Sharp);
14
+ require('./utility')(Sharp);
15
+
16
+ module.exports = Sharp;