sharp 0.23.0 → 0.23.4
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.
- package/README.md +3 -2
- package/binding.gyp +16 -10
- package/docs/api-composite.md +1 -0
- package/docs/api-constructor.md +1 -1
- package/docs/api-input.md +1 -0
- package/docs/api-output.md +96 -84
- package/docs/api-resize.md +2 -0
- package/docs/changelog.md +58 -0
- package/docs/index.md +7 -2
- package/docs/install.md +11 -4
- package/docs/performance.md +12 -13
- package/install/libvips.js +12 -7
- package/lib/agent.js +5 -2
- package/lib/colour.js +16 -12
- package/lib/composite.js +11 -1
- package/lib/constructor.js +2 -1
- package/lib/input.js +5 -0
- package/lib/operation.js +1 -1
- package/lib/output.js +29 -9
- package/lib/platform.js +1 -0
- package/lib/resize.js +17 -8
- package/package.json +29 -18
- package/src/common.cc +20 -13
- package/src/common.h +7 -5
- package/src/metadata.cc +14 -0
- package/src/metadata.h +5 -1
- package/src/operations.cc +26 -5
- package/src/pipeline.cc +17 -6
- package/src/pipeline.h +5 -1
- package/src/utilities.cc +3 -2
package/README.md
CHANGED
|
@@ -11,7 +11,8 @@ is to convert large images in common formats to
|
|
|
11
11
|
smaller, web-friendly JPEG, PNG and WebP images of varying dimensions.
|
|
12
12
|
|
|
13
13
|
Resizing an image is typically 4x-5x faster than using the
|
|
14
|
-
quickest ImageMagick and GraphicsMagick settings
|
|
14
|
+
quickest ImageMagick and GraphicsMagick settings
|
|
15
|
+
due to its use of [libvips](https://github.com/libvips/libvips).
|
|
15
16
|
|
|
16
17
|
Colour spaces, embedded ICC profiles and alpha transparency channels are all handled correctly.
|
|
17
18
|
Lanczos resampling ensures quality is not sacrificed for speed.
|
|
@@ -20,7 +21,7 @@ As well as image resizing, operations such as
|
|
|
20
21
|
rotation, extraction, compositing and gamma correction are available.
|
|
21
22
|
|
|
22
23
|
Most modern 64-bit OS X, Windows and Linux systems running
|
|
23
|
-
Node versions 8, 10 and
|
|
24
|
+
Node versions 8, 10, 12 and 13
|
|
24
25
|
do not require any additional install or runtime dependencies.
|
|
25
26
|
|
|
26
27
|
## Examples
|
package/binding.gyp
CHANGED
|
@@ -183,16 +183,22 @@
|
|
|
183
183
|
},
|
|
184
184
|
'configurations': {
|
|
185
185
|
'Release': {
|
|
186
|
-
'
|
|
187
|
-
'
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
186
|
+
'conditions': [
|
|
187
|
+
['OS == "linux"', {
|
|
188
|
+
'cflags_cc': [
|
|
189
|
+
'-Wno-cast-function-type'
|
|
190
|
+
]
|
|
191
|
+
}],
|
|
192
|
+
['OS == "win"', {
|
|
193
|
+
'msvs_settings': {
|
|
194
|
+
'VCCLCompilerTool': {
|
|
195
|
+
'ExceptionHandling': 1
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
'msvs_disabled_warnings': [
|
|
199
|
+
4275
|
|
200
|
+
]
|
|
201
|
+
}]
|
|
196
202
|
]
|
|
197
203
|
}
|
|
198
204
|
},
|
package/docs/api-composite.md
CHANGED
|
@@ -31,6 +31,7 @@ and [https://www.cairographics.org/operators/][2]
|
|
|
31
31
|
- `images[].top` **[Number][7]?** the pixel offset from the top edge.
|
|
32
32
|
- `images[].left` **[Number][7]?** the pixel offset from the left edge.
|
|
33
33
|
- `images[].tile` **[Boolean][9]** set to true to repeat the overlay image across the entire image with the given `gravity`. (optional, default `false`)
|
|
34
|
+
- `images[].premultiplied` **[Boolean][9]** set to true to avoid premultipling the image below. Equivalent to the `--premultiplied` vips option. (optional, default `false`)
|
|
34
35
|
- `images[].density` **[Number][7]** number representing the DPI for vector overlay image. (optional, default `72`)
|
|
35
36
|
- `images[].raw` **[Object][4]?** describes overlay when using raw pixel data.
|
|
36
37
|
- `images[].raw.width` **[Number][7]?**
|
package/docs/api-constructor.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- `input` **([Buffer][1] \| [String][2])?** if present, can be
|
|
8
8
|
a Buffer containing JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data, or
|
|
9
|
-
a String containing the path to an JPEG, PNG, WebP, GIF, SVG or TIFF image file.
|
|
9
|
+
a String containing the filesystem path to an JPEG, PNG, WebP, GIF, SVG or TIFF image file.
|
|
10
10
|
JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.
|
|
11
11
|
- `options` **[Object][3]?** if present, is an Object with optional attributes.
|
|
12
12
|
- `options.failOnError` **[Boolean][4]** by default halt processing and raise an error when loading invalid images.
|
package/docs/api-input.md
CHANGED
|
@@ -44,6 +44,7 @@ A `Promise` is returned when `callback` is not provided.
|
|
|
44
44
|
- `icc`: Buffer containing raw [ICC][3] profile data, if present
|
|
45
45
|
- `iptc`: Buffer containing raw IPTC data, if present
|
|
46
46
|
- `xmp`: Buffer containing raw XMP data, if present
|
|
47
|
+
- `tifftagPhotoshop`: Buffer containing raw TIFFTAG_PHOTOSHOP data, if present
|
|
47
48
|
|
|
48
49
|
### Parameters
|
|
49
50
|
|
package/docs/api-output.md
CHANGED
|
@@ -8,12 +8,15 @@ If an explicit output format is not selected, it will be inferred from the exten
|
|
|
8
8
|
with JPEG, PNG, WebP, TIFF, DZI, and libvips' V format supported.
|
|
9
9
|
Note that raw pixel data is only supported for buffer output.
|
|
10
10
|
|
|
11
|
+
By default all metadata will be removed, which includes EXIF-based orientation.
|
|
12
|
+
See [withMetadata][1] for control over this.
|
|
13
|
+
|
|
11
14
|
A `Promise` is returned when `callback` is not provided.
|
|
12
15
|
|
|
13
16
|
### Parameters
|
|
14
17
|
|
|
15
|
-
- `fileOut` **[String][
|
|
16
|
-
- `callback` **[Function][
|
|
18
|
+
- `fileOut` **[String][2]** the path to write the image data to.
|
|
19
|
+
- `callback` **[Function][3]?** called on completion with two arguments `(err, info)`.
|
|
17
20
|
`info` contains the output image `format`, `size` (bytes), `width`, `height`,
|
|
18
21
|
`channels` and `premultiplied` (indicating if premultiplication was used).
|
|
19
22
|
When using a crop strategy also contains `cropOffsetLeft` and `cropOffsetTop`.
|
|
@@ -32,15 +35,19 @@ sharp(input)
|
|
|
32
35
|
.catch(err => { ... });
|
|
33
36
|
```
|
|
34
37
|
|
|
35
|
-
- Throws **[Error][
|
|
38
|
+
- Throws **[Error][4]** Invalid parameters
|
|
36
39
|
|
|
37
|
-
Returns **[Promise][
|
|
40
|
+
Returns **[Promise][5]<[Object][6]>** when no callback is provided
|
|
38
41
|
|
|
39
42
|
## toBuffer
|
|
40
43
|
|
|
41
44
|
Write output to a Buffer.
|
|
42
45
|
JPEG, PNG, WebP, TIFF and RAW output are supported.
|
|
43
|
-
|
|
46
|
+
|
|
47
|
+
If no explicit format is set, the output format will match the input image, except GIF and SVG input which become PNG output.
|
|
48
|
+
|
|
49
|
+
By default all metadata will be removed, which includes EXIF-based orientation.
|
|
50
|
+
See [withMetadata][1] for control over this.
|
|
44
51
|
|
|
45
52
|
`callback`, if present, gets three arguments `(err, data, info)` where:
|
|
46
53
|
|
|
@@ -54,9 +61,9 @@ A `Promise` is returned when `callback` is not provided.
|
|
|
54
61
|
|
|
55
62
|
### Parameters
|
|
56
63
|
|
|
57
|
-
- `options` **[Object][
|
|
58
|
-
- `options.resolveWithObject` **[Boolean][
|
|
59
|
-
- `callback` **[Function][
|
|
64
|
+
- `options` **[Object][6]?**
|
|
65
|
+
- `options.resolveWithObject` **[Boolean][7]?** Resolve the Promise with an Object containing `data` and `info` properties instead of resolving only with `data`.
|
|
66
|
+
- `callback` **[Function][3]?**
|
|
60
67
|
|
|
61
68
|
### Examples
|
|
62
69
|
|
|
@@ -79,7 +86,7 @@ sharp(input)
|
|
|
79
86
|
.catch(err => { ... });
|
|
80
87
|
```
|
|
81
88
|
|
|
82
|
-
Returns **[Promise][
|
|
89
|
+
Returns **[Promise][5]<[Buffer][8]>** when no callback is provided
|
|
83
90
|
|
|
84
91
|
## withMetadata
|
|
85
92
|
|
|
@@ -89,8 +96,8 @@ This will also convert to and add a web-friendly sRGB ICC profile.
|
|
|
89
96
|
|
|
90
97
|
### Parameters
|
|
91
98
|
|
|
92
|
-
- `options` **[Object][
|
|
93
|
-
- `options.orientation` **[Number][
|
|
99
|
+
- `options` **[Object][6]?**
|
|
100
|
+
- `options.orientation` **[Number][9]?** value between 1 and 8, used to update the EXIF `Orientation` tag.
|
|
94
101
|
|
|
95
102
|
### Examples
|
|
96
103
|
|
|
@@ -101,7 +108,7 @@ sharp('input.jpg')
|
|
|
101
108
|
.then(info => { ... });
|
|
102
109
|
```
|
|
103
110
|
|
|
104
|
-
- Throws **[Error][
|
|
111
|
+
- Throws **[Error][4]** Invalid parameters
|
|
105
112
|
|
|
106
113
|
Returns **Sharp**
|
|
107
114
|
|
|
@@ -111,19 +118,19 @@ Use these JPEG options for output image.
|
|
|
111
118
|
|
|
112
119
|
### Parameters
|
|
113
120
|
|
|
114
|
-
- `options` **[Object][
|
|
115
|
-
- `options.quality` **[Number][
|
|
116
|
-
- `options.progressive` **[Boolean][
|
|
117
|
-
- `options.chromaSubsampling` **[String][
|
|
118
|
-
- `options.trellisQuantisation` **[Boolean][
|
|
119
|
-
- `options.overshootDeringing` **[Boolean][
|
|
120
|
-
- `options.optimiseScans` **[Boolean][
|
|
121
|
-
- `options.optimizeScans` **[Boolean][
|
|
122
|
-
- `options.optimiseCoding` **[Boolean][
|
|
123
|
-
- `options.optimizeCoding` **[Boolean][
|
|
124
|
-
- `options.quantisationTable` **[Number][
|
|
125
|
-
- `options.quantizationTable` **[Number][
|
|
126
|
-
- `options.force` **[Boolean][
|
|
121
|
+
- `options` **[Object][6]?** output options
|
|
122
|
+
- `options.quality` **[Number][9]** quality, integer 1-100 (optional, default `80`)
|
|
123
|
+
- `options.progressive` **[Boolean][7]** use progressive (interlace) scan (optional, default `false`)
|
|
124
|
+
- `options.chromaSubsampling` **[String][2]** set to '4:4:4' to prevent chroma subsampling when quality <= 90 (optional, default `'4:2:0'`)
|
|
125
|
+
- `options.trellisQuantisation` **[Boolean][7]** apply trellis quantisation, requires libvips compiled with support for mozjpeg (optional, default `false`)
|
|
126
|
+
- `options.overshootDeringing` **[Boolean][7]** apply overshoot deringing, requires libvips compiled with support for mozjpeg (optional, default `false`)
|
|
127
|
+
- `options.optimiseScans` **[Boolean][7]** optimise progressive scans, forces progressive, requires libvips compiled with support for mozjpeg (optional, default `false`)
|
|
128
|
+
- `options.optimizeScans` **[Boolean][7]** alternative spelling of optimiseScans (optional, default `false`)
|
|
129
|
+
- `options.optimiseCoding` **[Boolean][7]** optimise Huffman coding tables (optional, default `true`)
|
|
130
|
+
- `options.optimizeCoding` **[Boolean][7]** alternative spelling of optimiseCoding (optional, default `true`)
|
|
131
|
+
- `options.quantisationTable` **[Number][9]** quantization table to use, integer 0-8, requires libvips compiled with support for mozjpeg (optional, default `0`)
|
|
132
|
+
- `options.quantizationTable` **[Number][9]** alternative spelling of quantisationTable (optional, default `0`)
|
|
133
|
+
- `options.force` **[Boolean][7]** force JPEG output, otherwise attempt to use input format (optional, default `true`)
|
|
127
134
|
|
|
128
135
|
### Examples
|
|
129
136
|
|
|
@@ -137,7 +144,7 @@ const data = await sharp(input)
|
|
|
137
144
|
.toBuffer();
|
|
138
145
|
```
|
|
139
146
|
|
|
140
|
-
- Throws **[Error][
|
|
147
|
+
- Throws **[Error][4]** Invalid options
|
|
141
148
|
|
|
142
149
|
Returns **Sharp**
|
|
143
150
|
|
|
@@ -150,16 +157,16 @@ Indexed PNG input at 1, 2 or 4 bits per pixel is converted to 8 bits per pixel.
|
|
|
150
157
|
|
|
151
158
|
### Parameters
|
|
152
159
|
|
|
153
|
-
- `options` **[Object][
|
|
154
|
-
- `options.progressive` **[Boolean][
|
|
155
|
-
- `options.compressionLevel` **[Number][
|
|
156
|
-
- `options.adaptiveFiltering` **[Boolean][
|
|
157
|
-
- `options.palette` **[Boolean][
|
|
158
|
-
- `options.quality` **[Number][
|
|
159
|
-
- `options.colours` **[Number][
|
|
160
|
-
- `options.colors` **[Number][
|
|
161
|
-
- `options.dither` **[Number][
|
|
162
|
-
- `options.force` **[Boolean][
|
|
160
|
+
- `options` **[Object][6]?**
|
|
161
|
+
- `options.progressive` **[Boolean][7]** use progressive (interlace) scan (optional, default `false`)
|
|
162
|
+
- `options.compressionLevel` **[Number][9]** zlib compression level, 0-9 (optional, default `9`)
|
|
163
|
+
- `options.adaptiveFiltering` **[Boolean][7]** use adaptive row filtering (optional, default `false`)
|
|
164
|
+
- `options.palette` **[Boolean][7]** quantise to a palette-based image with alpha transparency support, requires libvips compiled with support for libimagequant (optional, default `false`)
|
|
165
|
+
- `options.quality` **[Number][9]** use the lowest number of colours needed to achieve given quality, requires libvips compiled with support for libimagequant (optional, default `100`)
|
|
166
|
+
- `options.colours` **[Number][9]** maximum number of palette entries, requires libvips compiled with support for libimagequant (optional, default `256`)
|
|
167
|
+
- `options.colors` **[Number][9]** alternative spelling of `options.colours`, requires libvips compiled with support for libimagequant (optional, default `256`)
|
|
168
|
+
- `options.dither` **[Number][9]** level of Floyd-Steinberg error diffusion, requires libvips compiled with support for libimagequant (optional, default `1.0`)
|
|
169
|
+
- `options.force` **[Boolean][7]** force PNG output, otherwise attempt to use input format (optional, default `true`)
|
|
163
170
|
|
|
164
171
|
### Examples
|
|
165
172
|
|
|
@@ -170,7 +177,7 @@ const data = await sharp(input)
|
|
|
170
177
|
.toBuffer();
|
|
171
178
|
```
|
|
172
179
|
|
|
173
|
-
- Throws **[Error][
|
|
180
|
+
- Throws **[Error][4]** Invalid options
|
|
174
181
|
|
|
175
182
|
Returns **Sharp**
|
|
176
183
|
|
|
@@ -180,14 +187,14 @@ Use these WebP options for output image.
|
|
|
180
187
|
|
|
181
188
|
### Parameters
|
|
182
189
|
|
|
183
|
-
- `options` **[Object][
|
|
184
|
-
- `options.quality` **[Number][
|
|
185
|
-
- `options.alphaQuality` **[Number][
|
|
186
|
-
- `options.lossless` **[Boolean][
|
|
187
|
-
- `options.nearLossless` **[Boolean][
|
|
188
|
-
- `options.smartSubsample` **[Boolean][
|
|
189
|
-
- `options.reductionEffort` **[Number][
|
|
190
|
-
- `options.force` **[Boolean][
|
|
190
|
+
- `options` **[Object][6]?** output options
|
|
191
|
+
- `options.quality` **[Number][9]** quality, integer 1-100 (optional, default `80`)
|
|
192
|
+
- `options.alphaQuality` **[Number][9]** quality of alpha layer, integer 0-100 (optional, default `100`)
|
|
193
|
+
- `options.lossless` **[Boolean][7]** use lossless compression mode (optional, default `false`)
|
|
194
|
+
- `options.nearLossless` **[Boolean][7]** use near_lossless compression mode (optional, default `false`)
|
|
195
|
+
- `options.smartSubsample` **[Boolean][7]** use high quality chroma subsampling (optional, default `false`)
|
|
196
|
+
- `options.reductionEffort` **[Number][9]** level of CPU effort to reduce file size, integer 0-6 (optional, default `4`)
|
|
197
|
+
- `options.force` **[Boolean][7]** force WebP output, otherwise attempt to use input format (optional, default `true`)
|
|
191
198
|
|
|
192
199
|
### Examples
|
|
193
200
|
|
|
@@ -198,7 +205,7 @@ const data = await sharp(input)
|
|
|
198
205
|
.toBuffer();
|
|
199
206
|
```
|
|
200
207
|
|
|
201
|
-
- Throws **[Error][
|
|
208
|
+
- Throws **[Error][4]** Invalid options
|
|
202
209
|
|
|
203
210
|
Returns **Sharp**
|
|
204
211
|
|
|
@@ -208,18 +215,18 @@ Use these TIFF options for output image.
|
|
|
208
215
|
|
|
209
216
|
### Parameters
|
|
210
217
|
|
|
211
|
-
- `options` **[Object][
|
|
212
|
-
- `options.quality` **[Number][
|
|
213
|
-
- `options.force` **[Boolean][
|
|
214
|
-
- `options.compression` **[Boolean][
|
|
215
|
-
- `options.predictor` **[Boolean][
|
|
216
|
-
- `options.pyramid` **[Boolean][
|
|
217
|
-
- `options.tile` **[Boolean][
|
|
218
|
-
- `options.tileWidth` **[Boolean][
|
|
219
|
-
- `options.tileHeight` **[Boolean][
|
|
220
|
-
- `options.xres` **[Number][
|
|
221
|
-
- `options.yres` **[Number][
|
|
222
|
-
- `options.squash` **[Boolean][
|
|
218
|
+
- `options` **[Object][6]?** output options
|
|
219
|
+
- `options.quality` **[Number][9]** quality, integer 1-100 (optional, default `80`)
|
|
220
|
+
- `options.force` **[Boolean][7]** force TIFF output, otherwise attempt to use input format (optional, default `true`)
|
|
221
|
+
- `options.compression` **[Boolean][7]** compression options: lzw, deflate, jpeg, ccittfax4 (optional, default `'jpeg'`)
|
|
222
|
+
- `options.predictor` **[Boolean][7]** compression predictor options: none, horizontal, float (optional, default `'horizontal'`)
|
|
223
|
+
- `options.pyramid` **[Boolean][7]** write an image pyramid (optional, default `false`)
|
|
224
|
+
- `options.tile` **[Boolean][7]** write a tiled tiff (optional, default `false`)
|
|
225
|
+
- `options.tileWidth` **[Boolean][7]** horizontal tile size (optional, default `256`)
|
|
226
|
+
- `options.tileHeight` **[Boolean][7]** vertical tile size (optional, default `256`)
|
|
227
|
+
- `options.xres` **[Number][9]** horizontal resolution in pixels/mm (optional, default `1.0`)
|
|
228
|
+
- `options.yres` **[Number][9]** vertical resolution in pixels/mm (optional, default `1.0`)
|
|
229
|
+
- `options.squash` **[Boolean][7]** squash 8-bit images down to 1 bit (optional, default `false`)
|
|
223
230
|
|
|
224
231
|
### Examples
|
|
225
232
|
|
|
@@ -234,7 +241,7 @@ sharp('input.svg')
|
|
|
234
241
|
.then(info => { ... });
|
|
235
242
|
```
|
|
236
243
|
|
|
237
|
-
- Throws **[Error][
|
|
244
|
+
- Throws **[Error][4]** Invalid options
|
|
238
245
|
|
|
239
246
|
Returns **Sharp**
|
|
240
247
|
|
|
@@ -251,13 +258,13 @@ Most versions of libheif support only the patent-encumbered HEVC compression for
|
|
|
251
258
|
|
|
252
259
|
### Parameters
|
|
253
260
|
|
|
254
|
-
- `options` **[Object][
|
|
255
|
-
- `options.quality` **[Number][
|
|
256
|
-
- `options.compression` **[Boolean][
|
|
257
|
-
- `options.lossless` **[Boolean][
|
|
261
|
+
- `options` **[Object][6]?** output options
|
|
262
|
+
- `options.quality` **[Number][9]** quality, integer 1-100 (optional, default `80`)
|
|
263
|
+
- `options.compression` **[Boolean][7]** compression format: hevc, avc, jpeg, av1 (optional, default `'hevc'`)
|
|
264
|
+
- `options.lossless` **[Boolean][7]** use lossless compression (optional, default `false`)
|
|
258
265
|
|
|
259
266
|
|
|
260
|
-
- Throws **[Error][
|
|
267
|
+
- Throws **[Error][4]** Invalid options
|
|
261
268
|
|
|
262
269
|
Returns **Sharp**
|
|
263
270
|
|
|
@@ -282,8 +289,8 @@ Force output to a given format.
|
|
|
282
289
|
|
|
283
290
|
### Parameters
|
|
284
291
|
|
|
285
|
-
- `format` **([String][
|
|
286
|
-
- `options` **[Object][
|
|
292
|
+
- `format` **([String][2] \| [Object][6])** as a String or an Object with an 'id' attribute
|
|
293
|
+
- `options` **[Object][6]** output options
|
|
287
294
|
|
|
288
295
|
### Examples
|
|
289
296
|
|
|
@@ -294,7 +301,7 @@ const data = await sharp(input)
|
|
|
294
301
|
.toBuffer();
|
|
295
302
|
```
|
|
296
303
|
|
|
297
|
-
- Throws **[Error][
|
|
304
|
+
- Throws **[Error][4]** unsupported format or options
|
|
298
305
|
|
|
299
306
|
Returns **Sharp**
|
|
300
307
|
|
|
@@ -308,14 +315,15 @@ Warning: multiple sharp instances concurrently producing tile output can expose
|
|
|
308
315
|
|
|
309
316
|
### Parameters
|
|
310
317
|
|
|
311
|
-
- `options` **[Object][
|
|
312
|
-
- `options.size` **[Number][
|
|
313
|
-
- `options.overlap` **[Number][
|
|
314
|
-
- `options.angle` **[Number][
|
|
315
|
-
- `options.
|
|
316
|
-
- `options.
|
|
317
|
-
- `options.
|
|
318
|
-
- `options.
|
|
318
|
+
- `options` **[Object][6]?**
|
|
319
|
+
- `options.size` **[Number][9]** tile size in pixels, a value between 1 and 8192. (optional, default `256`)
|
|
320
|
+
- `options.overlap` **[Number][9]** tile overlap in pixels, a value between 0 and 8192. (optional, default `0`)
|
|
321
|
+
- `options.angle` **[Number][9]** tile angle of rotation, must be a multiple of 90. (optional, default `0`)
|
|
322
|
+
- `options.background` **([String][2] \| [Object][6])** background colour, parsed by the [color][10] module, defaults to white without transparency. (optional, default `{r:255,g:255,b:255,alpha:1}`)
|
|
323
|
+
- `options.depth` **[String][2]?** how deep to make the pyramid, possible values are `onepixel`, `onetile` or `one`, default based on layout.
|
|
324
|
+
- `options.skipBlanks` **[Number][9]** threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images (optional, default `-1`)
|
|
325
|
+
- `options.container` **[String][2]** tile container, with value `fs` (filesystem) or `zip` (compressed file). (optional, default `'fs'`)
|
|
326
|
+
- `options.layout` **[String][2]** filesystem layout, possible values are `dz`, `zoomify` or `google`. (optional, default `'dz'`)
|
|
319
327
|
|
|
320
328
|
### Examples
|
|
321
329
|
|
|
@@ -331,22 +339,26 @@ sharp('input.tiff')
|
|
|
331
339
|
});
|
|
332
340
|
```
|
|
333
341
|
|
|
334
|
-
- Throws **[Error][
|
|
342
|
+
- Throws **[Error][4]** Invalid parameters
|
|
335
343
|
|
|
336
344
|
Returns **Sharp**
|
|
337
345
|
|
|
338
|
-
[1]:
|
|
346
|
+
[1]: #withmetadata
|
|
347
|
+
|
|
348
|
+
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
349
|
+
|
|
350
|
+
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
339
351
|
|
|
340
|
-
[
|
|
352
|
+
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
|
341
353
|
|
|
342
|
-
[
|
|
354
|
+
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
343
355
|
|
|
344
|
-
[
|
|
356
|
+
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
345
357
|
|
|
346
|
-
[
|
|
358
|
+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
347
359
|
|
|
348
|
-
[
|
|
360
|
+
[8]: https://nodejs.org/api/buffer.html
|
|
349
361
|
|
|
350
|
-
[
|
|
362
|
+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
351
363
|
|
|
352
|
-
[
|
|
364
|
+
[10]: https://www.npmjs.org/package/color
|
package/docs/api-resize.md
CHANGED
|
@@ -196,6 +196,8 @@ Returns **Sharp**
|
|
|
196
196
|
## trim
|
|
197
197
|
|
|
198
198
|
Trim "boring" pixels from all edges that contain values similar to the top-left pixel.
|
|
199
|
+
Images consisting entirely of a single colour will calculate "boring" using the alpha channel, if any.
|
|
200
|
+
|
|
199
201
|
The `info` response Object will contain `trimOffsetLeft` and `trimOffsetTop` properties.
|
|
200
202
|
|
|
201
203
|
### Parameters
|
package/docs/changelog.md
CHANGED
|
@@ -4,6 +4,64 @@
|
|
|
4
4
|
|
|
5
5
|
Requires libvips v8.8.1.
|
|
6
6
|
|
|
7
|
+
#### v0.23.4 - 5<sup>th</sup> December 2019
|
|
8
|
+
|
|
9
|
+
* Handle zero-length Buffer objects when using Node.js v13.2.0+.
|
|
10
|
+
|
|
11
|
+
* Expose raw TIFFTAG_PHOTOSHOP metadata.
|
|
12
|
+
[#1600](https://github.com/lovell/sharp/issues/1600)
|
|
13
|
+
|
|
14
|
+
* Improve thread safety by using copy-on-write when updating metadata.
|
|
15
|
+
[#1986](https://github.com/lovell/sharp/issues/1986)
|
|
16
|
+
|
|
17
|
+
#### v0.23.3 - 17<sup>th</sup> November 2019
|
|
18
|
+
|
|
19
|
+
* Ensure `trim` operation supports images contained in the alpha channel.
|
|
20
|
+
[#1597](https://github.com/lovell/sharp/issues/1597)
|
|
21
|
+
|
|
22
|
+
* Ensure tile `overlap` option works as expected.
|
|
23
|
+
[#1921](https://github.com/lovell/sharp/pull/1921)
|
|
24
|
+
[@rustyguts](https://github.com/rustyguts)
|
|
25
|
+
|
|
26
|
+
* Allow compilation on FreeBSD and variants (broken since v0.23.0)
|
|
27
|
+
[#1952](https://github.com/lovell/sharp/pull/1952)
|
|
28
|
+
[@pouya-eghbali](https://github.com/pouya-eghbali)
|
|
29
|
+
|
|
30
|
+
* Ensure `modulate` and other colour-based operations can co-exist.
|
|
31
|
+
[#1958](https://github.com/lovell/sharp/issues/1958)
|
|
32
|
+
|
|
33
|
+
#### v0.23.2 - 28<sup>th</sup> October 2019
|
|
34
|
+
|
|
35
|
+
* Add `background` option to tile output operation.
|
|
36
|
+
[#1924](https://github.com/lovell/sharp/pull/1924)
|
|
37
|
+
[@neave](https://github.com/neave)
|
|
38
|
+
|
|
39
|
+
* Add support for Node.js 13.
|
|
40
|
+
[#1932](https://github.com/lovell/sharp/pull/1932)
|
|
41
|
+
[@MayhemYDG](https://github.com/MayhemYDG)
|
|
42
|
+
|
|
43
|
+
#### v0.23.1 - 26<sup>th</sup> September 2019
|
|
44
|
+
|
|
45
|
+
* Ensure `sharp.format.vips` is present and correct (filesystem only).
|
|
46
|
+
[#1813](https://github.com/lovell/sharp/issues/1813)
|
|
47
|
+
|
|
48
|
+
* Ensure invalid `width` and `height` provided as options to `resize` throw.
|
|
49
|
+
[#1817](https://github.com/lovell/sharp/issues/1817)
|
|
50
|
+
|
|
51
|
+
* Allow use of 'heic' and 'heif' identifiers with `toFormat`.
|
|
52
|
+
[#1834](https://github.com/lovell/sharp/pull/1834)
|
|
53
|
+
[@jaubourg](https://github.com/jaubourg)
|
|
54
|
+
|
|
55
|
+
* Add `premultiplied` option to `composite` operation.
|
|
56
|
+
[#1835](https://github.com/lovell/sharp/pull/1835)
|
|
57
|
+
[@Andargor](https://github.com/Andargor)
|
|
58
|
+
|
|
59
|
+
* Allow instance reuse with differing `toBuffer` options.
|
|
60
|
+
[#1860](https://github.com/lovell/sharp/pull/1860)
|
|
61
|
+
[@RaboliotTheGrey](https://github.com/RaboliotTheGrey)
|
|
62
|
+
|
|
63
|
+
* Ensure image is at least 3x3 pixels before attempting trim operation.
|
|
64
|
+
|
|
7
65
|
#### v0.23.0 - 29<sup>th</sup> July 2019
|
|
8
66
|
|
|
9
67
|
* Remove `overlayWith` previously deprecated in v0.22.0.
|
package/docs/index.md
CHANGED
|
@@ -7,7 +7,8 @@ is to convert large images in common formats to
|
|
|
7
7
|
smaller, web-friendly JPEG, PNG and WebP images of varying dimensions.
|
|
8
8
|
|
|
9
9
|
Resizing an image is typically 4x-5x faster than using the
|
|
10
|
-
quickest ImageMagick and GraphicsMagick settings
|
|
10
|
+
quickest ImageMagick and GraphicsMagick settings
|
|
11
|
+
due to its use of [libvips](https://github.com/libvips/libvips).
|
|
11
12
|
|
|
12
13
|
Colour spaces, embedded ICC profiles and alpha transparency channels are all handled correctly.
|
|
13
14
|
Lanczos resampling ensures quality is not sacrificed for speed.
|
|
@@ -16,7 +17,7 @@ As well as image resizing, operations such as
|
|
|
16
17
|
rotation, extraction, compositing and gamma correction are available.
|
|
17
18
|
|
|
18
19
|
Most modern 64-bit OS X, Windows and Linux systems running
|
|
19
|
-
Node versions 8, 10 and
|
|
20
|
+
Node versions 8, 10, 12 and 13
|
|
20
21
|
do not require any additional install or runtime dependencies.
|
|
21
22
|
|
|
22
23
|
[](https://coveralls.io/r/lovell/sharp?branch=master)
|
|
@@ -126,6 +127,10 @@ the help and code contributions of the following people:
|
|
|
126
127
|
* [Michael B. Klein](https://github.com/mbklein)
|
|
127
128
|
* [Jakub Michálek](https://github.com/Goues)
|
|
128
129
|
* [Ilya Ovdin](https://github.com/iovdin)
|
|
130
|
+
* [Andargor](https://github.com/Andargor)
|
|
131
|
+
* [Nicolas Stepien](https://github.com/MayhemYDG)
|
|
132
|
+
* [Paul Neave](https://github.com/neave)
|
|
133
|
+
* [Brendan Kennedy](https://github.com/rustyguts)
|
|
129
134
|
|
|
130
135
|
Thank you!
|
|
131
136
|
|
package/docs/install.md
CHANGED
|
@@ -15,7 +15,7 @@ yarn add sharp
|
|
|
15
15
|
### Building from source
|
|
16
16
|
|
|
17
17
|
Pre-compiled binaries for sharp are provided for use with
|
|
18
|
-
Node versions 8, 10 and
|
|
18
|
+
Node versions 8, 10, 12 and 13 on
|
|
19
19
|
64-bit Windows, OS X and Linux platforms.
|
|
20
20
|
|
|
21
21
|
Sharp will be built from source at install time when:
|
|
@@ -74,9 +74,8 @@ libvips is available in the
|
|
|
74
74
|
[community repository](https://pkgs.alpinelinux.org/packages?name=vips-dev):
|
|
75
75
|
|
|
76
76
|
```sh
|
|
77
|
-
apk add
|
|
78
|
-
|
|
79
|
-
--repository https://alpine.global.ssl.fastly.net/alpine/edge/main
|
|
77
|
+
apk add --upgrade --no-cache vips-dev build-base \
|
|
78
|
+
--repository https://alpine.global.ssl.fastly.net/alpine/v3.10/community/
|
|
80
79
|
```
|
|
81
80
|
|
|
82
81
|
The smaller stack size of musl libc means
|
|
@@ -107,6 +106,8 @@ Only 64-bit (x64) `node.exe` is supported.
|
|
|
107
106
|
|
|
108
107
|
### FreeBSD
|
|
109
108
|
|
|
109
|
+
[](https://cirrus-ci.com/github/lovell/sharp)
|
|
110
|
+
|
|
110
111
|
libvips must be installed before `npm install` is run.
|
|
111
112
|
|
|
112
113
|
This can be achieved via package or ports:
|
|
@@ -127,6 +128,9 @@ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=193528
|
|
|
127
128
|
Set [NODE_MODULES_CACHE](https://devcenter.heroku.com/articles/nodejs-support#cache-behavior)
|
|
128
129
|
to `false` when using the `yarn` package manager.
|
|
129
130
|
|
|
131
|
+
To reduce the effects of memory fragmentation, add the
|
|
132
|
+
[jemalloc buildpack](https://github.com/gaffneyc/heroku-buildpack-jemalloc).
|
|
133
|
+
|
|
130
134
|
### Docker
|
|
131
135
|
|
|
132
136
|
[Marc Bachmann](https://github.com/marcbachmann) maintains an
|
|
@@ -247,6 +251,9 @@ SHARP_DIST_BASE_URL="https://hostname/path/" npm install sharp
|
|
|
247
251
|
|
|
248
252
|
to use `https://hostname/path/libvips-x.y.z-platform.tar.gz`.
|
|
249
253
|
|
|
254
|
+
To install the prebuilt sharp binaries from a custom URL, please see
|
|
255
|
+
[https://github.com/prebuild/prebuild-install#custom-binaries](https://github.com/prebuild/prebuild-install#custom-binaries)
|
|
256
|
+
|
|
250
257
|
### Licences
|
|
251
258
|
|
|
252
259
|
This module is licensed under the terms of the
|
package/docs/performance.md
CHANGED
|
@@ -4,16 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
* AWS EC2 eu-west-1 [c5.large](https://aws.amazon.com/ec2/instance-types/c5/) (2x Xeon Platinum 8124M CPU @ 3.00GHz)
|
|
6
6
|
* Ubuntu 18.04 (hvm-ssd/ubuntu-bionic-18.04-amd64-server-20180912 ami-00035f41c82244dab)
|
|
7
|
-
* Node.js
|
|
7
|
+
* Node.js v12.10.0
|
|
8
8
|
|
|
9
9
|
### The contenders
|
|
10
10
|
|
|
11
|
-
* [jimp](https://www.npmjs.com/package/jimp) v0.
|
|
12
|
-
* [mapnik](https://www.npmjs.org/package/mapnik) v4.
|
|
13
|
-
* [imagemagick-native](https://www.npmjs.com/package/imagemagick-native) v1.9.3 - Wrapper around libmagick++, supports Buffers only.
|
|
11
|
+
* [jimp](https://www.npmjs.com/package/jimp) v0.8.4 - Image processing in pure JavaScript. Provides bicubic interpolation.
|
|
12
|
+
* [mapnik](https://www.npmjs.org/package/mapnik) v4.3.1 - Whilst primarily a map renderer, Mapnik contains bitmap image utilities.
|
|
14
13
|
* [imagemagick](https://www.npmjs.com/package/imagemagick) v0.1.3 - Supports filesystem only and "*has been unmaintained for a long time*".
|
|
15
14
|
* [gm](https://www.npmjs.com/package/gm) v1.23.1 - Fully featured wrapper around GraphicsMagick's `gm` command line utility.
|
|
16
|
-
* sharp v0.
|
|
15
|
+
* sharp v0.23.1 / libvips v8.8.1 - Caching within libvips disabled to ensure a fair comparison.
|
|
17
16
|
|
|
18
17
|
### The task
|
|
19
18
|
|
|
@@ -25,14 +24,14 @@ then compress to JPEG at a "quality" setting of 80.
|
|
|
25
24
|
|
|
26
25
|
| Module | Input | Output | Ops/sec | Speed-up |
|
|
27
26
|
| :----------------- | :----- | :----- | ------: | -------: |
|
|
28
|
-
| jimp | buffer | buffer | 0.
|
|
29
|
-
| mapnik | buffer | buffer | 3.
|
|
30
|
-
| gm | buffer | buffer | 3.
|
|
31
|
-
|
|
|
32
|
-
| imagemagick | file | file | 4.
|
|
33
|
-
| sharp | stream | stream | 25.
|
|
34
|
-
| sharp | file | file | 26.
|
|
35
|
-
| sharp | buffer | buffer |
|
|
27
|
+
| jimp | buffer | buffer | 0.66 | 1.0 |
|
|
28
|
+
| mapnik | buffer | buffer | 3.31 | 5.0 |
|
|
29
|
+
| gm | buffer | buffer | 3.79 | 5.7 |
|
|
30
|
+
| gm | file | file | 3.82 | 5.8 |
|
|
31
|
+
| imagemagick | file | file | 4.17 | 6.3 |
|
|
32
|
+
| sharp | stream | stream | 25.81 | 39.1 |
|
|
33
|
+
| sharp | file | file | 26.76 | 40.5 |
|
|
34
|
+
| sharp | buffer | buffer | 28.06 | 42.5 |
|
|
36
35
|
|
|
37
36
|
Greater libvips performance can be expected with caching enabled (default)
|
|
38
37
|
and using 8+ core machines, especially those with larger L1/L2 CPU caches.
|