sharp 0.20.5 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/binding.gyp +5 -0
- package/docs/api-channel.md +16 -0
- package/docs/api-colour.md +1 -19
- package/docs/api-composite.md +2 -3
- package/docs/api-constructor.md +2 -2
- package/docs/api-input.md +6 -2
- package/docs/api-operation.md +40 -115
- package/docs/api-output.md +3 -0
- package/docs/api-resize.md +159 -109
- package/docs/api-utility.md +4 -7
- package/docs/changelog.md +87 -0
- package/docs/index.md +10 -4
- package/docs/install.md +18 -38
- package/docs/performance.md +14 -21
- package/install/dll-copy.js +3 -2
- package/install/libvips.js +55 -36
- package/lib/channel.js +18 -0
- package/lib/colour.js +34 -15
- package/lib/composite.js +2 -3
- package/lib/constructor.js +19 -41
- package/lib/input.js +7 -3
- package/lib/libvips.js +38 -6
- package/lib/operation.js +27 -118
- package/lib/output.js +22 -2
- package/lib/platform.js +4 -1
- package/lib/resize.js +308 -104
- package/lib/utility.js +5 -8
- package/package.json +20 -13
- package/src/common.cc +50 -13
- package/src/common.h +12 -10
- package/src/libvips/cplusplus/VImage.cpp +95 -95
- package/src/libvips/cplusplus/vips-operators.cpp +268 -185
- package/src/metadata.cc +15 -0
- package/src/metadata.h +3 -0
- package/src/operations.cc +27 -54
- package/src/operations.h +6 -1
- package/src/pipeline.cc +81 -89
- package/src/pipeline.h +25 -13
- package/src/stats.cc +11 -8
- package/src/stats.h +3 -1
- package/src/utilities.cc +1 -1
package/docs/api-resize.md
CHANGED
|
@@ -2,181 +2,231 @@
|
|
|
2
2
|
|
|
3
3
|
## resize
|
|
4
4
|
|
|
5
|
-
Resize image to `width` x
|
|
6
|
-
By default, the resized image is centre cropped to the exact size specified.
|
|
5
|
+
Resize image to `width`, `height` or `width x height`.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
When both a `width` and `height` are provided, the possible methods by which the image should **fit** these are:
|
|
9
8
|
|
|
10
|
-
- `
|
|
11
|
-
- `
|
|
12
|
-
- `
|
|
9
|
+
- `cover`: Crop to cover both provided dimensions (the default).
|
|
10
|
+
- `contain`: Embed within both provided dimensions.
|
|
11
|
+
- `fill`: Ignore the aspect ratio of the input and stretch to both provided dimensions.
|
|
12
|
+
- `inside`: Preserving aspect ratio, resize the image to be as large as possible while ensuring its dimensions are less than or equal to both those specified.
|
|
13
|
+
- `outside`: Preserving aspect ratio, resize the image to be as small as possible while ensuring its dimensions are greater than or equal to both those specified.
|
|
14
|
+
Some of these values are based on the [object-fit][1] CSS property.
|
|
15
|
+
|
|
16
|
+
When using a `fit` of `cover` or `contain`, the default **position** is `centre`. Other options are:
|
|
17
|
+
|
|
18
|
+
- `sharp.position`: `top`, `right top`, `right`, `right bottom`, `bottom`, `left bottom`, `left`, `left top`.
|
|
19
|
+
- `sharp.gravity`: `north`, `northeast`, `east`, `southeast`, `south`, `southwest`, `west`, `northwest`, `center` or `centre`.
|
|
20
|
+
- `sharp.strategy`: `cover` only, dynamically crop using either the `entropy` or `attention` strategy.
|
|
21
|
+
Some of these values are based on the [object-position][2] CSS property.
|
|
22
|
+
|
|
23
|
+
The experimental strategy-based approach resizes so one dimension is at its target length
|
|
24
|
+
then repeatedly ranks edge regions, discarding the edge with the lowest score based on the selected strategy.
|
|
25
|
+
|
|
26
|
+
- `entropy`: focus on the region with the highest [Shannon entropy][3].
|
|
27
|
+
- `attention`: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
|
|
28
|
+
|
|
29
|
+
Possible interpolation kernels are:
|
|
30
|
+
|
|
31
|
+
- `nearest`: Use [nearest neighbour interpolation][4].
|
|
32
|
+
- `cubic`: Use a [Catmull-Rom spline][5].
|
|
33
|
+
- `lanczos2`: Use a [Lanczos kernel][6] with `a=2`.
|
|
13
34
|
- `lanczos3`: Use a Lanczos kernel with `a=3` (the default).
|
|
14
35
|
|
|
15
36
|
### Parameters
|
|
16
37
|
|
|
17
|
-
- `width` **[Number][
|
|
18
|
-
- `height` **[Number][
|
|
19
|
-
- `options` **[Object][
|
|
20
|
-
- `options.
|
|
21
|
-
- `options.
|
|
38
|
+
- `width` **[Number][7]?** pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height.
|
|
39
|
+
- `height` **[Number][7]?** pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.
|
|
40
|
+
- `options` **[Object][8]?**
|
|
41
|
+
- `options.width` **[String][9]?** alternative means of specifying `width`. If both are present this take priority.
|
|
42
|
+
- `options.height` **[String][9]?** alternative means of specifying `height`. If both are present this take priority.
|
|
43
|
+
- `options.fit` **[String][9]** how the image should be resized to fit both provided dimensions, one of `cover`, `contain`, `fill`, `inside` or `outside`. (optional, default `'cover'`)
|
|
44
|
+
- `options.position` **[String][9]** position, gravity or strategy to use when `fit` is `cover` or `contain`. (optional, default `'centre'`)
|
|
45
|
+
- `options.background` **([String][9] \| [Object][8])** background colour when using a `fit` of `contain`, parsed by the [color][10] module, defaults to black without transparency. (optional, default `{r:0,g:0,b:0,alpha:1}`)
|
|
46
|
+
- `options.kernel` **[String][9]** the kernel to use for image reduction. (optional, default `'lanczos3'`)
|
|
47
|
+
- `options.withoutEnlargement` **[Boolean][11]** do not enlarge if the width _or_ height are already less than the specified dimensions, equivalent to GraphicsMagick's `>` geometry option. (optional, default `false`)
|
|
48
|
+
- `options.fastShrinkOnLoad` **[Boolean][11]** take greater advantage of the JPEG and WebP shrink-on-load feature, which can lead to a slight moiré pattern on some images. (optional, default `true`)
|
|
22
49
|
|
|
23
50
|
### Examples
|
|
24
51
|
|
|
25
52
|
```javascript
|
|
26
|
-
sharp(
|
|
53
|
+
sharp(input)
|
|
54
|
+
.resize({ width: 100 })
|
|
55
|
+
.toBuffer()
|
|
56
|
+
.then(data => {
|
|
57
|
+
// 100 pixels wide, auto-scaled height
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
sharp(input)
|
|
63
|
+
.resize({ height: 100 })
|
|
64
|
+
.toBuffer()
|
|
65
|
+
.then(data => {
|
|
66
|
+
// 100 pixels high, auto-scaled width
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
sharp(input)
|
|
27
72
|
.resize(200, 300, {
|
|
28
|
-
kernel: sharp.kernel.nearest
|
|
73
|
+
kernel: sharp.kernel.nearest,
|
|
74
|
+
fit: 'contain',
|
|
75
|
+
position: 'right top',
|
|
76
|
+
background: { r: 255, g: 255, b: 255, alpha: 0.5 }
|
|
29
77
|
})
|
|
30
|
-
.
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
// containing a nearest-neighbour scaled version, embedded on a white canvas,
|
|
36
|
-
// of the image data in inputBuffer
|
|
78
|
+
.toFile('output.png')
|
|
79
|
+
.then(() => {
|
|
80
|
+
// output.png is a 200 pixels wide and 300 pixels high image
|
|
81
|
+
// containing a nearest-neighbour scaled version
|
|
82
|
+
// contained within the north-east corner of a semi-transparent white canvas
|
|
37
83
|
});
|
|
38
84
|
```
|
|
39
85
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
86
|
+
```javascript
|
|
87
|
+
const transformer = sharp()
|
|
88
|
+
.resize({
|
|
89
|
+
width: 200,
|
|
90
|
+
height: 200,
|
|
91
|
+
fit: sharp.fit.cover,
|
|
92
|
+
position: sharp.strategy.entropy
|
|
93
|
+
});
|
|
94
|
+
// Read image data from readableStream
|
|
95
|
+
// Write 200px square auto-cropped image data to writableStream
|
|
96
|
+
readableStream
|
|
97
|
+
.pipe(transformer)
|
|
98
|
+
.pipe(writableStream);
|
|
99
|
+
```
|
|
43
100
|
|
|
44
|
-
|
|
101
|
+
```javascript
|
|
102
|
+
sharp(input)
|
|
103
|
+
.resize(200, 200, {
|
|
104
|
+
fit: sharp.fit.inside,
|
|
105
|
+
withoutEnlargement: true
|
|
106
|
+
})
|
|
107
|
+
.toFormat('jpeg')
|
|
108
|
+
.toBuffer()
|
|
109
|
+
.then(function(outputBuffer) {
|
|
110
|
+
// outputBuffer contains JPEG image data
|
|
111
|
+
// no wider and no higher than 200 pixels
|
|
112
|
+
// and no larger than the input image
|
|
113
|
+
});
|
|
114
|
+
```
|
|
45
115
|
|
|
46
|
-
|
|
116
|
+
- Throws **[Error][12]** Invalid parameters
|
|
47
117
|
|
|
48
|
-
|
|
49
|
-
`southwest`, `west`, `northwest`, `center` and `centre`.
|
|
118
|
+
Returns **Sharp**
|
|
50
119
|
|
|
51
|
-
|
|
52
|
-
then repeatedly ranks edge regions, discarding the edge with the lowest score based on the selected strategy.
|
|
120
|
+
## extend
|
|
53
121
|
|
|
54
|
-
|
|
55
|
-
|
|
122
|
+
Extends/pads the edges of the image with the provided background colour.
|
|
123
|
+
This operation will always occur after resizing and extraction, if any.
|
|
56
124
|
|
|
57
125
|
### Parameters
|
|
58
126
|
|
|
59
|
-
- `
|
|
127
|
+
- `extend` **([Number][7] \| [Object][8])** single pixel count to add to all edges or an Object with per-edge counts
|
|
128
|
+
- `extend.top` **[Number][7]?**
|
|
129
|
+
- `extend.left` **[Number][7]?**
|
|
130
|
+
- `extend.bottom` **[Number][7]?**
|
|
131
|
+
- `extend.right` **[Number][7]?**
|
|
132
|
+
- `extend.background` **([String][9] \| [Object][8])** background colour, parsed by the [color][10] module, defaults to black without transparency. (optional, default `{r:0,g:0,b:0,alpha:1}`)
|
|
60
133
|
|
|
61
134
|
### Examples
|
|
62
135
|
|
|
63
136
|
```javascript
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
137
|
+
// Resize to 140 pixels wide, then add 10 transparent pixels
|
|
138
|
+
// to the top, left and right edges and 20 to the bottom edge
|
|
139
|
+
sharp(input)
|
|
140
|
+
.resize(140)
|
|
141
|
+
.)
|
|
142
|
+
.extend({
|
|
143
|
+
top: 10,
|
|
144
|
+
bottom: 20,
|
|
145
|
+
left: 10,
|
|
146
|
+
right: 10
|
|
147
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 }
|
|
148
|
+
})
|
|
149
|
+
...
|
|
73
150
|
```
|
|
74
151
|
|
|
75
|
-
- Throws **[Error][
|
|
152
|
+
- Throws **[Error][12]** Invalid parameters
|
|
76
153
|
|
|
77
154
|
Returns **Sharp**
|
|
78
155
|
|
|
79
|
-
##
|
|
156
|
+
## extract
|
|
80
157
|
|
|
81
|
-
|
|
82
|
-
then embed on a background of the exact `width` and `height` specified.
|
|
158
|
+
Extract a region of the image.
|
|
83
159
|
|
|
84
|
-
|
|
85
|
-
|
|
160
|
+
- Use `extract` before `resize` for pre-resize extraction.
|
|
161
|
+
- Use `extract` after `resize` for post-resize extraction.
|
|
162
|
+
- Use `extract` before and after for both.
|
|
86
163
|
|
|
87
164
|
### Parameters
|
|
88
165
|
|
|
89
|
-
- `
|
|
166
|
+
- `options` **[Object][8]**
|
|
167
|
+
- `options.left` **[Number][7]** zero-indexed offset from left edge
|
|
168
|
+
- `options.top` **[Number][7]** zero-indexed offset from top edge
|
|
169
|
+
- `options.width` **[Number][7]** dimension of extracted image
|
|
170
|
+
- `options.height` **[Number][7]** dimension of extracted image
|
|
90
171
|
|
|
91
172
|
### Examples
|
|
92
173
|
|
|
93
174
|
```javascript
|
|
94
|
-
sharp(
|
|
95
|
-
.
|
|
96
|
-
.
|
|
97
|
-
|
|
98
|
-
.toFormat(sharp.format.webp)
|
|
99
|
-
.toBuffer(function(err, outputBuffer) {
|
|
100
|
-
if (err) {
|
|
101
|
-
throw err;
|
|
102
|
-
}
|
|
103
|
-
// outputBuffer contains WebP image data of a 200 pixels wide and 300 pixels high
|
|
104
|
-
// containing a scaled version, embedded on a transparent canvas, of input.gif
|
|
175
|
+
sharp(input)
|
|
176
|
+
.extract({ left: left, top: top, width: width, height: height })
|
|
177
|
+
.toFile(output, function(err) {
|
|
178
|
+
// Extract a region of the input image, saving in the same format.
|
|
105
179
|
});
|
|
106
180
|
```
|
|
107
181
|
|
|
108
|
-
- Throws **[Error][8]** Invalid parameters
|
|
109
|
-
|
|
110
|
-
Returns **Sharp**
|
|
111
|
-
|
|
112
|
-
## max
|
|
113
|
-
|
|
114
|
-
Preserving aspect ratio, resize the image to be as large as possible
|
|
115
|
-
while ensuring its dimensions are less than or equal to the `width` and `height` specified.
|
|
116
|
-
|
|
117
|
-
Both `width` and `height` must be provided via `resize` otherwise the behaviour will default to `crop`.
|
|
118
|
-
|
|
119
|
-
### Examples
|
|
120
|
-
|
|
121
182
|
```javascript
|
|
122
|
-
sharp(
|
|
123
|
-
.
|
|
124
|
-
.
|
|
125
|
-
.
|
|
126
|
-
.
|
|
127
|
-
|
|
128
|
-
// outputBuffer contains JPEG image data no wider than 200 pixels and no higher
|
|
129
|
-
// than 200 pixels regardless of the inputBuffer image dimensions
|
|
183
|
+
sharp(input)
|
|
184
|
+
.extract({ left: leftOffsetPre, top: topOffsetPre, width: widthPre, height: heightPre })
|
|
185
|
+
.resize(width, height)
|
|
186
|
+
.extract({ left: leftOffsetPost, top: topOffsetPost, width: widthPost, height: heightPost })
|
|
187
|
+
.toFile(output, function(err) {
|
|
188
|
+
// Extract a region, resize, then extract from the resized image
|
|
130
189
|
});
|
|
131
190
|
```
|
|
132
191
|
|
|
192
|
+
- Throws **[Error][12]** Invalid parameters
|
|
193
|
+
|
|
133
194
|
Returns **Sharp**
|
|
134
195
|
|
|
135
|
-
##
|
|
196
|
+
## trim
|
|
136
197
|
|
|
137
|
-
|
|
138
|
-
|
|
198
|
+
Trim "boring" pixels from all edges that contain values similar to the top-left pixel.
|
|
199
|
+
The `info` response Object will contain `trimOffsetLeft` and `trimOffsetTop` properties.
|
|
139
200
|
|
|
140
|
-
|
|
201
|
+
### Parameters
|
|
141
202
|
|
|
142
|
-
|
|
203
|
+
- `threshold` **[Number][7]** the allowed difference from the top-left pixel, a number greater than zero. (optional, default `10`)
|
|
143
204
|
|
|
144
|
-
## ignoreAspectRatio
|
|
145
205
|
|
|
146
|
-
|
|
147
|
-
the exact `width` and/or `height` provided via `resize`.
|
|
206
|
+
- Throws **[Error][12]** Invalid parameters
|
|
148
207
|
|
|
149
208
|
Returns **Sharp**
|
|
150
209
|
|
|
151
|
-
|
|
210
|
+
[1]: https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
|
|
152
211
|
|
|
153
|
-
|
|
154
|
-
This is equivalent to GraphicsMagick's `>` geometry option:
|
|
155
|
-
"_change the dimensions of the image only if its width or height exceeds the geometry specification_".
|
|
156
|
-
Use with `max()` to preserve the image's aspect ratio.
|
|
212
|
+
[2]: https://developer.mozilla.org/en-US/docs/Web/CSS/object-position
|
|
157
213
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
### Parameters
|
|
161
|
-
|
|
162
|
-
- `withoutEnlargement` **[Boolean][7]** (optional, default `true`)
|
|
163
|
-
|
|
164
|
-
Returns **Sharp**
|
|
214
|
+
[3]: https://en.wikipedia.org/wiki/Entropy_%28information_theory%29
|
|
165
215
|
|
|
166
|
-
[
|
|
216
|
+
[4]: http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation
|
|
167
217
|
|
|
168
|
-
[
|
|
218
|
+
[5]: https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline
|
|
169
219
|
|
|
170
|
-
[
|
|
220
|
+
[6]: https://en.wikipedia.org/wiki/Lanczos_resampling#Lanczos_kernel
|
|
171
221
|
|
|
172
|
-
[
|
|
222
|
+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
173
223
|
|
|
174
|
-
[
|
|
224
|
+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
175
225
|
|
|
176
|
-
[
|
|
226
|
+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
177
227
|
|
|
178
|
-
[
|
|
228
|
+
[10]: https://www.npmjs.org/package/color
|
|
179
229
|
|
|
180
|
-
[
|
|
230
|
+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
181
231
|
|
|
182
|
-
[
|
|
232
|
+
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
package/docs/api-utility.md
CHANGED
|
@@ -77,23 +77,20 @@ Requires libvips to have been compiled with liborc support.
|
|
|
77
77
|
Improves the performance of `resize`, `blur` and `sharpen` operations
|
|
78
78
|
by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.
|
|
79
79
|
|
|
80
|
-
This feature is currently off by default but future versions may reverse this.
|
|
81
|
-
Versions of liborc prior to 0.4.25 are known to segfault under heavy load.
|
|
82
|
-
|
|
83
80
|
### Parameters
|
|
84
81
|
|
|
85
|
-
- `simd` **[Boolean][2]** (optional, default `
|
|
82
|
+
- `simd` **[Boolean][2]** (optional, default `true`)
|
|
86
83
|
|
|
87
84
|
### Examples
|
|
88
85
|
|
|
89
86
|
```javascript
|
|
90
87
|
const simd = sharp.simd();
|
|
91
|
-
// simd is `true` if
|
|
88
|
+
// simd is `true` if the runtime use of liborc is currently enabled
|
|
92
89
|
```
|
|
93
90
|
|
|
94
91
|
```javascript
|
|
95
|
-
const simd = sharp.simd(
|
|
96
|
-
//
|
|
92
|
+
const simd = sharp.simd(false);
|
|
93
|
+
// prevent libvips from using liborc at runtime
|
|
97
94
|
```
|
|
98
95
|
|
|
99
96
|
Returns **[Boolean][2]**
|
package/docs/changelog.md
CHANGED
|
@@ -1,9 +1,96 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### v0.21 - "*teeth*"
|
|
4
|
+
|
|
5
|
+
Requires libvips v8.7.0.
|
|
6
|
+
|
|
7
|
+
#### v0.21.0 - 4<sup>th</sup> October 2018
|
|
8
|
+
|
|
9
|
+
* Deprecate the following resize-related functions:
|
|
10
|
+
`crop`, `embed`, `ignoreAspectRatio`, `max`, `min` and `withoutEnlargement`.
|
|
11
|
+
Access to these is now via options passed to the `resize` function.
|
|
12
|
+
For example:
|
|
13
|
+
`embed('north')` is now `resize(width, height, { fit: 'contain', position: 'north' })`,
|
|
14
|
+
`crop('attention')` is now `resize(width, height, { fit: 'cover', position: 'attention' })`,
|
|
15
|
+
`max().withoutEnlargement()` is now `resize(width, height, { fit: 'inside', withoutEnlargement: true })`.
|
|
16
|
+
[#1135](https://github.com/lovell/sharp/issues/1135)
|
|
17
|
+
|
|
18
|
+
* Deprecate the `background` function.
|
|
19
|
+
Per-operation `background` options added to `resize`, `extend` and `flatten` operations.
|
|
20
|
+
[#1392](https://github.com/lovell/sharp/issues/1392)
|
|
21
|
+
|
|
22
|
+
* Add `size` to `metadata` response (Stream and Buffer input only).
|
|
23
|
+
[#695](https://github.com/lovell/sharp/issues/695)
|
|
24
|
+
|
|
25
|
+
* Switch from custom trim operation to `vips_find_trim`.
|
|
26
|
+
[#914](https://github.com/lovell/sharp/issues/914)
|
|
27
|
+
|
|
28
|
+
* Add `chromaSubsampling` and `isProgressive` properties to `metadata` response.
|
|
29
|
+
[#1186](https://github.com/lovell/sharp/issues/1186)
|
|
30
|
+
|
|
31
|
+
* Drop Node 4 support.
|
|
32
|
+
[#1212](https://github.com/lovell/sharp/issues/1212)
|
|
33
|
+
|
|
34
|
+
* Enable SIMD convolution by default.
|
|
35
|
+
[#1213](https://github.com/lovell/sharp/issues/1213)
|
|
36
|
+
|
|
37
|
+
* Add experimental prebuilt binaries for musl-based Linux.
|
|
38
|
+
[#1379](https://github.com/lovell/sharp/issues/1379)
|
|
39
|
+
|
|
40
|
+
* Add support for arbitrary rotation angle via vips_rotate.
|
|
41
|
+
[#1385](https://github.com/lovell/sharp/pull/1385)
|
|
42
|
+
[@freezy](https://github.com/freezy)
|
|
43
|
+
|
|
3
44
|
### v0.20 - "*prebuild*"
|
|
4
45
|
|
|
5
46
|
Requires libvips v8.6.1.
|
|
6
47
|
|
|
48
|
+
#### v0.20.8 - 5<sup>th</sup> September 2018
|
|
49
|
+
|
|
50
|
+
* Avoid race conditions when creating directories during installation.
|
|
51
|
+
[#1358](https://github.com/lovell/sharp/pull/1358)
|
|
52
|
+
[@ajhool](https://github.com/ajhool)
|
|
53
|
+
|
|
54
|
+
* Accept floating point values for input density parameter.
|
|
55
|
+
[#1362](https://github.com/lovell/sharp/pull/1362)
|
|
56
|
+
[@aeirola](https://github.com/aeirola)
|
|
57
|
+
|
|
58
|
+
#### v0.20.7 - 21<sup>st</sup> August 2018
|
|
59
|
+
|
|
60
|
+
* Use copy+unlink if rename operation fails during installation.
|
|
61
|
+
[#1345](https://github.com/lovell/sharp/issues/1345)
|
|
62
|
+
|
|
63
|
+
#### v0.20.6 - 20<sup>th</sup> August 2018
|
|
64
|
+
|
|
65
|
+
* Add removeAlpha operation to remove alpha channel, if any.
|
|
66
|
+
[#1248](https://github.com/lovell/sharp/issues/1248)
|
|
67
|
+
|
|
68
|
+
* Expose mozjpeg quant_table flag.
|
|
69
|
+
[#1285](https://github.com/lovell/sharp/pull/1285)
|
|
70
|
+
[@rexxars](https://github.com/rexxars)
|
|
71
|
+
|
|
72
|
+
* Allow full WebP alphaQuality range of 0-100.
|
|
73
|
+
[#1290](https://github.com/lovell/sharp/pull/1290)
|
|
74
|
+
[@sylvaindumont](https://github.com/sylvaindumont)
|
|
75
|
+
|
|
76
|
+
* Cache libvips binaries to reduce re-install time.
|
|
77
|
+
[#1301](https://github.com/lovell/sharp/issues/1301)
|
|
78
|
+
|
|
79
|
+
* Ensure vendor platform mismatch throws error at install time.
|
|
80
|
+
[#1303](https://github.com/lovell/sharp/issues/1303)
|
|
81
|
+
|
|
82
|
+
* Improve install time error messages for FreeBSD users.
|
|
83
|
+
[#1310](https://github.com/lovell/sharp/issues/1310)
|
|
84
|
+
|
|
85
|
+
* Ensure extractChannel works with 16-bit images.
|
|
86
|
+
[#1330](https://github.com/lovell/sharp/issues/1330)
|
|
87
|
+
|
|
88
|
+
* Expose depth option for tile-based output.
|
|
89
|
+
[#1342](https://github.com/lovell/sharp/pull/1342)
|
|
90
|
+
[@alundavies](https://github.com/alundavies)
|
|
91
|
+
|
|
92
|
+
* Add experimental entropy field to stats response.
|
|
93
|
+
|
|
7
94
|
#### v0.20.5 - 27<sup>th</sup> June 2018
|
|
8
95
|
|
|
9
96
|
* Expose libjpeg optimize_coding flag.
|
package/docs/index.md
CHANGED
|
@@ -13,8 +13,8 @@ Lanczos resampling ensures quality is not sacrificed for speed.
|
|
|
13
13
|
As well as image resizing, operations such as
|
|
14
14
|
rotation, extraction, compositing and gamma correction are available.
|
|
15
15
|
|
|
16
|
-
Most 64-bit OS X, Windows and Linux
|
|
17
|
-
Node versions
|
|
16
|
+
Most modern 64-bit OS X, Windows and Linux systems running
|
|
17
|
+
Node versions 6, 8 and 10
|
|
18
18
|
do not require any additional install or runtime dependencies.
|
|
19
19
|
|
|
20
20
|
[](https://coveralls.io/r/lovell/sharp?branch=master)
|
|
@@ -37,7 +37,7 @@ and [Leaflet](https://github.com/turban/Leaflet.Zoomify).
|
|
|
37
37
|
### Fast
|
|
38
38
|
|
|
39
39
|
This module is powered by the blazingly fast
|
|
40
|
-
[libvips](https://github.com/
|
|
40
|
+
[libvips](https://github.com/libvips/libvips) image processing library,
|
|
41
41
|
originally created in 1989 at Birkbeck College
|
|
42
42
|
and currently maintained by
|
|
43
43
|
[John Cupitt](https://github.com/jcupitt).
|
|
@@ -113,10 +113,16 @@ the help and code contributions of the following people:
|
|
|
113
113
|
* [Thomas Parisot](https://github.com/oncletom)
|
|
114
114
|
* [Nathan Graves](https://github.com/woolite64)
|
|
115
115
|
* [Tom Lokhorst](https://github.com/tomlokhorst)
|
|
116
|
+
* [Espen Hovlandsdal](https://github.com/rexxars)
|
|
117
|
+
* [Sylvain Dumont](https://github.com/sylvaindumont)
|
|
118
|
+
* [Alun Davies](https://github.com/alundavies)
|
|
119
|
+
* [Aidan Hoolachan](https://github.com/ajhool)
|
|
120
|
+
* [Axel Eirola](https://github.com/aeirola)
|
|
121
|
+
* [Freezy](https://github.com/freezy)
|
|
116
122
|
|
|
117
123
|
Thank you!
|
|
118
124
|
|
|
119
|
-
###
|
|
125
|
+
### Licensing
|
|
120
126
|
|
|
121
127
|
Copyright 2013, 2014, 2015, 2016, 2017, 2018 Lovell Fuller and contributors.
|
|
122
128
|
|
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
|
|
18
|
+
Node versions 6, 8 and 10 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:
|
|
@@ -27,7 +27,7 @@ Sharp will be built from source at install time when:
|
|
|
27
27
|
Building from source requires:
|
|
28
28
|
|
|
29
29
|
* C++11 compatible compiler such as gcc 4.8+, clang 3.0+ or MSVC 2013+
|
|
30
|
-
* [node-gyp](https://github.com/
|
|
30
|
+
* [node-gyp](https://github.com/nodejs/node-gyp#installation) and its dependencies (includes Python 2.7)
|
|
31
31
|
|
|
32
32
|
## libvips
|
|
33
33
|
|
|
@@ -36,13 +36,14 @@ Building from source requires:
|
|
|
36
36
|
[](https://travis-ci.org/lovell/sharp)
|
|
37
37
|
|
|
38
38
|
libvips and its dependencies are fetched and stored within `node_modules/sharp/vendor` during `npm install`.
|
|
39
|
-
This involves an automated HTTPS download of approximately
|
|
39
|
+
This involves an automated HTTPS download of approximately 8MB.
|
|
40
40
|
|
|
41
|
-
Most
|
|
41
|
+
Most Linux-based (glibc, musl) operating systems running on x64 and ARMv6+ CPUs should "just work", e.g.:
|
|
42
42
|
|
|
43
43
|
* Debian 7+
|
|
44
44
|
* Ubuntu 14.04+
|
|
45
45
|
* Centos 7+
|
|
46
|
+
* Alpine 3.8+ (Node 8 and 10)
|
|
46
47
|
* Fedora
|
|
47
48
|
* openSUSE 13.2+
|
|
48
49
|
* Archlinux
|
|
@@ -61,9 +62,9 @@ and `LD_LIBRARY_PATH` at runtime.
|
|
|
61
62
|
This allows the use of newer versions of libvips with older versions of sharp.
|
|
62
63
|
|
|
63
64
|
For 32-bit Intel CPUs and older Linux-based operating systems such as Centos 6,
|
|
64
|
-
|
|
65
|
+
compiling libvips from source is recommended.
|
|
65
66
|
|
|
66
|
-
https://
|
|
67
|
+
[https://libvips.github.io/libvips/install.html#building-libvips-from-a-source-tarball](https://libvips.github.io/libvips/install.html#building-libvips-from-a-source-tarball)
|
|
67
68
|
|
|
68
69
|
#### Alpine Linux
|
|
69
70
|
|
|
@@ -71,7 +72,7 @@ libvips is available in the
|
|
|
71
72
|
[testing repository](https://pkgs.alpinelinux.org/packages?name=vips-dev):
|
|
72
73
|
|
|
73
74
|
```sh
|
|
74
|
-
apk add vips-dev fftw-dev --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/
|
|
75
|
+
apk add vips-dev fftw-dev build-base --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/
|
|
75
76
|
```
|
|
76
77
|
|
|
77
78
|
The smaller stack size of musl libc means
|
|
@@ -94,7 +95,7 @@ that it can be located using `pkg-config --modversion vips-cpp`.
|
|
|
94
95
|
[](https://ci.appveyor.com/project/lovell/sharp)
|
|
95
96
|
|
|
96
97
|
libvips and its dependencies are fetched and stored within `node_modules\sharp\vendor` during `npm install`.
|
|
97
|
-
This involves an automated HTTPS download of approximately
|
|
98
|
+
This involves an automated HTTPS download of approximately 13MB.
|
|
98
99
|
|
|
99
100
|
Only 64-bit (x64) `node.exe` is supported.
|
|
100
101
|
|
|
@@ -117,9 +118,6 @@ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=193528
|
|
|
117
118
|
|
|
118
119
|
### Heroku
|
|
119
120
|
|
|
120
|
-
libvips and its dependencies are fetched and stored within `node_modules\sharp\vendor` during `npm install`.
|
|
121
|
-
This involves an automated HTTPS download of approximately 7MB.
|
|
122
|
-
|
|
123
121
|
Set [NODE_MODULES_CACHE](https://devcenter.heroku.com/articles/nodejs-support#cache-behavior)
|
|
124
122
|
to `false` when using the `yarn` package manager.
|
|
125
123
|
|
|
@@ -154,12 +152,13 @@ can be built using Docker.
|
|
|
154
152
|
|
|
155
153
|
```sh
|
|
156
154
|
rm -rf node_modules/sharp
|
|
157
|
-
docker run -v "$PWD":/var/task lambci/lambda:build-
|
|
155
|
+
docker run -v "$PWD":/var/task lambci/lambda:build-nodejs8.10 npm install
|
|
158
156
|
```
|
|
159
157
|
|
|
160
|
-
Set the Lambda runtime to Node.js
|
|
158
|
+
Set the Lambda runtime to Node.js 8.10.
|
|
161
159
|
|
|
162
|
-
To get the best performance select the largest memory available.
|
|
160
|
+
To get the best performance select the largest memory available.
|
|
161
|
+
A 1536 MB function provides ~12x more CPU time than a 128 MB function.
|
|
163
162
|
|
|
164
163
|
### NW.js
|
|
165
164
|
|
|
@@ -171,7 +170,7 @@ nw-gyp rebuild --arch=x64 --target=[your nw version]
|
|
|
171
170
|
node node_modules/sharp/install/dll-copy
|
|
172
171
|
```
|
|
173
172
|
|
|
174
|
-
|
|
173
|
+
[http://docs.nwjs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/](http://docs.nwjs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/)
|
|
175
174
|
|
|
176
175
|
### Build tools
|
|
177
176
|
|
|
@@ -199,28 +198,6 @@ and [Valgrind](http://valgrind.org/) have been used to test
|
|
|
199
198
|
the most popular web-based formats, as well as libvips itself,
|
|
200
199
|
you are advised to perform your own testing and sandboxing.
|
|
201
200
|
|
|
202
|
-
ImageMagick in particular has a relatively large attack surface,
|
|
203
|
-
which can be partially mitigated with a
|
|
204
|
-
[policy.xml](http://www.imagemagick.org/script/resources.php)
|
|
205
|
-
configuration file to prevent the use of coders known to be vulnerable.
|
|
206
|
-
|
|
207
|
-
```xml
|
|
208
|
-
<policymap>
|
|
209
|
-
<policy domain="coder" rights="none" pattern="EPHEMERAL" />
|
|
210
|
-
<policy domain="coder" rights="none" pattern="URL" />
|
|
211
|
-
<policy domain="coder" rights="none" pattern="HTTPS" />
|
|
212
|
-
<policy domain="coder" rights="none" pattern="MVG" />
|
|
213
|
-
<policy domain="coder" rights="none" pattern="MSL" />
|
|
214
|
-
<policy domain="coder" rights="none" pattern="TEXT" />
|
|
215
|
-
<policy domain="coder" rights="none" pattern="SHOW" />
|
|
216
|
-
<policy domain="coder" rights="none" pattern="WIN" />
|
|
217
|
-
<policy domain="coder" rights="none" pattern="PLT" />
|
|
218
|
-
</policymap>
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
Set the `MAGICK_CONFIGURE_PATH` environment variable
|
|
222
|
-
to the directory containing the `policy.xml` file.
|
|
223
|
-
|
|
224
201
|
### Pre-compiled libvips binaries
|
|
225
202
|
|
|
226
203
|
This module will attempt to download a pre-compiled bundle of libvips
|
|
@@ -236,7 +213,8 @@ SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install sharp
|
|
|
236
213
|
```
|
|
237
214
|
|
|
238
215
|
Should you need to manually download and inspect these files,
|
|
239
|
-
you can do so via
|
|
216
|
+
you can do so via
|
|
217
|
+
[https://github.com/lovell/sharp-libvips/releases](https://github.com/lovell/sharp-libvips/releases)
|
|
240
218
|
|
|
241
219
|
Should you wish to install these from your own location,
|
|
242
220
|
set the `SHARP_DIST_BASE_URL` environment variable, e.g.
|
|
@@ -265,6 +243,8 @@ Use of libraries under the terms of the LGPLv3 is via the
|
|
|
265
243
|
| expat | MIT Licence |
|
|
266
244
|
| fontconfig | [fontconfig Licence](https://cgit.freedesktop.org/fontconfig/tree/COPYING) (BSD-like) |
|
|
267
245
|
| freetype | [freetype Licence](http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) |
|
|
246
|
+
| fribidi | LGPLv3 |
|
|
247
|
+
| gettext | LGPLv3 |
|
|
268
248
|
| giflib | MIT Licence |
|
|
269
249
|
| glib | LGPLv3 |
|
|
270
250
|
| harfbuzz | MIT Licence |
|