sharp 0.29.1 → 0.30.1
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 +5 -5
- package/binding.gyp +2 -0
- package/install/libvips.js +39 -8
- package/lib/constructor.js +13 -4
- package/lib/input.js +21 -4
- package/lib/libvips.js +16 -2
- package/lib/operation.js +14 -1
- package/lib/output.js +158 -69
- package/lib/platform.js +1 -1
- package/lib/resize.js +19 -0
- package/lib/sharp.js +11 -3
- package/lib/utility.js +24 -5
- package/package.json +28 -13
- package/src/common.cc +125 -19
- package/src/common.h +39 -5
- package/src/libvips/cplusplus/VImage.cpp +34 -16
- package/src/libvips/cplusplus/vips-operators.cpp +29 -1
- package/src/metadata.cc +6 -0
- package/src/metadata.h +1 -0
- package/src/operations.cc +94 -0
- package/src/operations.h +12 -0
- package/src/pipeline.cc +291 -255
- package/src/pipeline.h +19 -19
- package/src/sharp.cc +16 -0
package/src/pipeline.h
CHANGED
|
@@ -27,14 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
Napi::Value pipeline(const Napi::CallbackInfo& info);
|
|
29
29
|
|
|
30
|
-
enum class Canvas {
|
|
31
|
-
CROP,
|
|
32
|
-
EMBED,
|
|
33
|
-
MAX,
|
|
34
|
-
MIN,
|
|
35
|
-
IGNORE_ASPECT
|
|
36
|
-
};
|
|
37
|
-
|
|
38
30
|
struct Composite {
|
|
39
31
|
sharp::InputDescriptor *input;
|
|
40
32
|
VipsBlendMode mode;
|
|
@@ -75,7 +67,7 @@ struct PipelineBaton {
|
|
|
75
67
|
int width;
|
|
76
68
|
int height;
|
|
77
69
|
int channels;
|
|
78
|
-
Canvas canvas;
|
|
70
|
+
sharp::Canvas canvas;
|
|
79
71
|
int position;
|
|
80
72
|
std::vector<double> resizeBackground;
|
|
81
73
|
bool hasCropOffset;
|
|
@@ -127,13 +119,14 @@ struct PipelineBaton {
|
|
|
127
119
|
int extendRight;
|
|
128
120
|
std::vector<double> extendBackground;
|
|
129
121
|
bool withoutEnlargement;
|
|
122
|
+
bool withoutReduction;
|
|
130
123
|
std::vector<double> affineMatrix;
|
|
131
124
|
std::vector<double> affineBackground;
|
|
132
125
|
double affineIdx;
|
|
133
126
|
double affineIdy;
|
|
134
127
|
double affineOdx;
|
|
135
128
|
double affineOdy;
|
|
136
|
-
|
|
129
|
+
std::string affineInterpolator;
|
|
137
130
|
int jpegQuality;
|
|
138
131
|
bool jpegProgressive;
|
|
139
132
|
std::string jpegChromaSubsampling;
|
|
@@ -147,6 +140,7 @@ struct PipelineBaton {
|
|
|
147
140
|
bool pngAdaptiveFiltering;
|
|
148
141
|
bool pngPalette;
|
|
149
142
|
int pngQuality;
|
|
143
|
+
int pngEffort;
|
|
150
144
|
int pngBitdepth;
|
|
151
145
|
double pngDither;
|
|
152
146
|
int jp2Quality;
|
|
@@ -159,7 +153,10 @@ struct PipelineBaton {
|
|
|
159
153
|
bool webpNearLossless;
|
|
160
154
|
bool webpLossless;
|
|
161
155
|
bool webpSmartSubsample;
|
|
162
|
-
int
|
|
156
|
+
int webpEffort;
|
|
157
|
+
int gifBitdepth;
|
|
158
|
+
int gifEffort;
|
|
159
|
+
double gifDither;
|
|
163
160
|
int tiffQuality;
|
|
164
161
|
VipsForeignTiffCompression tiffCompression;
|
|
165
162
|
VipsForeignTiffPredictor tiffPredictor;
|
|
@@ -170,9 +167,10 @@ struct PipelineBaton {
|
|
|
170
167
|
int tiffTileWidth;
|
|
171
168
|
double tiffXres;
|
|
172
169
|
double tiffYres;
|
|
170
|
+
VipsForeignTiffResunit tiffResolutionUnit;
|
|
173
171
|
int heifQuality;
|
|
174
172
|
VipsForeignHeifCompression heifCompression;
|
|
175
|
-
int
|
|
173
|
+
int heifEffort;
|
|
176
174
|
std::string heifChromaSubsampling;
|
|
177
175
|
bool heifLossless;
|
|
178
176
|
VipsBandFormat rawDepth;
|
|
@@ -182,6 +180,7 @@ struct PipelineBaton {
|
|
|
182
180
|
double withMetadataDensity;
|
|
183
181
|
std::string withMetadataIcc;
|
|
184
182
|
std::unordered_map<std::string, std::string> withMetadataStrs;
|
|
183
|
+
int timeoutSeconds;
|
|
185
184
|
std::unique_ptr<double[]> convKernel;
|
|
186
185
|
int convKernelWidth;
|
|
187
186
|
int convKernelHeight;
|
|
@@ -195,7 +194,6 @@ struct PipelineBaton {
|
|
|
195
194
|
double ensureAlpha;
|
|
196
195
|
VipsInterpretation colourspaceInput;
|
|
197
196
|
VipsInterpretation colourspace;
|
|
198
|
-
int pageHeight;
|
|
199
197
|
std::vector<int> delay;
|
|
200
198
|
int loop;
|
|
201
199
|
int tileSize;
|
|
@@ -216,7 +214,7 @@ struct PipelineBaton {
|
|
|
216
214
|
topOffsetPre(-1),
|
|
217
215
|
topOffsetPost(-1),
|
|
218
216
|
channels(0),
|
|
219
|
-
canvas(Canvas::CROP),
|
|
217
|
+
canvas(sharp::Canvas::CROP),
|
|
220
218
|
position(0),
|
|
221
219
|
resizeBackground{ 0.0, 0.0, 0.0, 255.0 },
|
|
222
220
|
hasCropOffset(false),
|
|
@@ -263,13 +261,14 @@ struct PipelineBaton {
|
|
|
263
261
|
extendRight(0),
|
|
264
262
|
extendBackground{ 0.0, 0.0, 0.0, 255.0 },
|
|
265
263
|
withoutEnlargement(false),
|
|
264
|
+
withoutReduction(false),
|
|
266
265
|
affineMatrix{ 1.0, 0.0, 0.0, 1.0 },
|
|
267
266
|
affineBackground{ 0.0, 0.0, 0.0, 255.0 },
|
|
268
267
|
affineIdx(0),
|
|
269
268
|
affineIdy(0),
|
|
270
269
|
affineOdx(0),
|
|
271
270
|
affineOdy(0),
|
|
272
|
-
affineInterpolator(
|
|
271
|
+
affineInterpolator("bicubic"),
|
|
273
272
|
jpegQuality(80),
|
|
274
273
|
jpegProgressive(false),
|
|
275
274
|
jpegChromaSubsampling("4:2:0"),
|
|
@@ -283,6 +282,7 @@ struct PipelineBaton {
|
|
|
283
282
|
pngAdaptiveFiltering(false),
|
|
284
283
|
pngPalette(false),
|
|
285
284
|
pngQuality(100),
|
|
285
|
+
pngEffort(7),
|
|
286
286
|
pngBitdepth(8),
|
|
287
287
|
pngDither(1.0),
|
|
288
288
|
jp2Quality(80),
|
|
@@ -295,7 +295,7 @@ struct PipelineBaton {
|
|
|
295
295
|
webpNearLossless(false),
|
|
296
296
|
webpLossless(false),
|
|
297
297
|
webpSmartSubsample(false),
|
|
298
|
-
|
|
298
|
+
webpEffort(4),
|
|
299
299
|
tiffQuality(80),
|
|
300
300
|
tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
|
|
301
301
|
tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
|
|
@@ -306,15 +306,17 @@ struct PipelineBaton {
|
|
|
306
306
|
tiffTileWidth(256),
|
|
307
307
|
tiffXres(1.0),
|
|
308
308
|
tiffYres(1.0),
|
|
309
|
+
tiffResolutionUnit(VIPS_FOREIGN_TIFF_RESUNIT_INCH),
|
|
309
310
|
heifQuality(50),
|
|
310
311
|
heifCompression(VIPS_FOREIGN_HEIF_COMPRESSION_AV1),
|
|
311
|
-
|
|
312
|
+
heifEffort(4),
|
|
312
313
|
heifChromaSubsampling("4:4:4"),
|
|
313
314
|
heifLossless(false),
|
|
314
315
|
rawDepth(VIPS_FORMAT_UCHAR),
|
|
315
316
|
withMetadata(false),
|
|
316
317
|
withMetadataOrientation(-1),
|
|
317
318
|
withMetadataDensity(0.0),
|
|
319
|
+
timeoutSeconds(0),
|
|
318
320
|
convKernelWidth(0),
|
|
319
321
|
convKernelHeight(0),
|
|
320
322
|
convKernelScale(0.0),
|
|
@@ -327,8 +329,6 @@ struct PipelineBaton {
|
|
|
327
329
|
ensureAlpha(-1.0),
|
|
328
330
|
colourspaceInput(VIPS_INTERPRETATION_LAST),
|
|
329
331
|
colourspace(VIPS_INTERPRETATION_LAST),
|
|
330
|
-
pageHeight(0),
|
|
331
|
-
delay{-1},
|
|
332
332
|
loop(-1),
|
|
333
333
|
tileSize(256),
|
|
334
334
|
tileOverlap(0),
|
package/src/sharp.cc
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
|
|
15
15
|
#include <napi.h>
|
|
16
|
+
#include <cstdlib>
|
|
16
17
|
#include <vips/vips8>
|
|
17
18
|
|
|
18
19
|
#include "common.h"
|
|
@@ -21,6 +22,14 @@
|
|
|
21
22
|
#include "utilities.h"
|
|
22
23
|
#include "stats.h"
|
|
23
24
|
|
|
25
|
+
#if defined(_MSC_VER) && _MSC_VER >= 1400 // MSVC 2005/8
|
|
26
|
+
static void empty_invalid_parameter_handler(const wchar_t* expression,
|
|
27
|
+
const wchar_t* function, const wchar_t* file, unsigned int line,
|
|
28
|
+
uintptr_t reserved) {
|
|
29
|
+
// No-op.
|
|
30
|
+
}
|
|
31
|
+
#endif
|
|
32
|
+
|
|
24
33
|
static void* sharp_vips_init(void*) {
|
|
25
34
|
g_setenv("VIPS_MIN_STACK_SIZE", "2m", FALSE);
|
|
26
35
|
vips_init("sharp");
|
|
@@ -34,6 +43,13 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
|
|
|
34
43
|
g_log_set_handler("VIPS", static_cast<GLogLevelFlags>(G_LOG_LEVEL_WARNING),
|
|
35
44
|
static_cast<GLogFunc>(sharp::VipsWarningCallback), nullptr);
|
|
36
45
|
|
|
46
|
+
// Tell the CRT to not exit the application when an invalid parameter is
|
|
47
|
+
// passed. The main issue is that invalid FDs will trigger this behaviour.
|
|
48
|
+
// See: https://github.com/libvips/libvips/pull/2571.
|
|
49
|
+
#if defined(_MSC_VER) && _MSC_VER >= 1400 // MSVC 2005/8
|
|
50
|
+
_set_invalid_parameter_handler(empty_invalid_parameter_handler);
|
|
51
|
+
#endif
|
|
52
|
+
|
|
37
53
|
// Methods available to JavaScript
|
|
38
54
|
exports.Set("metadata", Napi::Function::New(env, metadata));
|
|
39
55
|
exports.Set("pipeline", Napi::Function::New(env, pipeline));
|