sharp 0.33.5 → 0.35.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 +12 -18
- package/dist/channel.cjs +177 -0
- package/{lib/channel.js → dist/channel.mjs} +11 -8
- package/dist/colour.cjs +195 -0
- package/{lib/colour.js → dist/colour.mjs} +38 -23
- package/dist/composite.cjs +213 -0
- package/{lib/composite.js → dist/composite.mjs} +14 -11
- package/{lib/constructor.js → dist/constructor.cjs} +102 -43
- package/dist/constructor.mjs +511 -0
- package/dist/index.cjs +25 -0
- package/dist/index.mjs +25 -0
- package/dist/input.cjs +814 -0
- package/{lib/input.js → dist/input.mjs} +224 -68
- package/{lib/is.js → dist/is.cjs} +19 -45
- package/dist/is.mjs +143 -0
- package/{lib/libvips.js → dist/libvips.cjs} +52 -43
- package/dist/libvips.mjs +212 -0
- package/dist/operation.cjs +987 -0
- package/{lib/operation.js → dist/operation.mjs} +108 -79
- package/{lib/output.js → dist/output.cjs} +243 -36
- package/dist/output.mjs +1794 -0
- package/dist/resize.cjs +613 -0
- package/{lib/resize.js → dist/resize.mjs} +38 -12
- package/dist/sharp.cjs +164 -0
- package/dist/sharp.mjs +164 -0
- package/{lib/utility.js → dist/utility.cjs} +23 -24
- package/dist/utility.mjs +295 -0
- package/install/build.js +38 -0
- package/lib/index.d.ts +347 -125
- package/package.json +75 -84
- package/src/binding.gyp +49 -26
- package/src/common.cc +203 -111
- package/src/common.h +68 -40
- package/src/metadata.cc +106 -22
- package/src/metadata.h +15 -5
- package/src/operations.cc +62 -21
- package/src/operations.h +15 -3
- package/src/pipeline.cc +374 -183
- package/src/pipeline.h +34 -7
- package/src/sharp.cc +11 -8
- package/src/stats.cc +16 -13
- package/src/stats.h +6 -3
- package/src/utilities.cc +32 -12
- package/src/utilities.h +5 -2
- package/install/check.js +0 -41
- package/lib/index.js +0 -16
- package/lib/sharp.js +0 -114
package/src/pipeline.h
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
3
5
|
|
|
4
6
|
#ifndef SRC_PIPELINE_H_
|
|
5
7
|
#define SRC_PIPELINE_H_
|
|
6
8
|
|
|
7
9
|
#include <memory>
|
|
8
10
|
#include <string>
|
|
9
|
-
#include <vector>
|
|
10
11
|
#include <unordered_map>
|
|
12
|
+
#include <vector>
|
|
11
13
|
|
|
12
14
|
#include <napi.h>
|
|
13
15
|
#include <vips/vips8>
|
|
@@ -39,12 +41,14 @@ struct Composite {
|
|
|
39
41
|
|
|
40
42
|
struct PipelineBaton {
|
|
41
43
|
sharp::InputDescriptor *input;
|
|
44
|
+
std::vector<sharp::InputDescriptor *> join;
|
|
42
45
|
std::string formatOut;
|
|
43
46
|
std::string fileOut;
|
|
44
47
|
void *bufferOut;
|
|
45
48
|
size_t bufferOutLength;
|
|
46
49
|
int pageHeightOut;
|
|
47
50
|
int pagesOut;
|
|
51
|
+
bool typedArrayOut;
|
|
48
52
|
std::vector<Composite *> composite;
|
|
49
53
|
std::vector<sharp::InputDescriptor *> joinChannelIn;
|
|
50
54
|
int topOffsetPre;
|
|
@@ -98,8 +102,11 @@ struct PipelineBaton {
|
|
|
98
102
|
bool trimLineArt;
|
|
99
103
|
int trimOffsetLeft;
|
|
100
104
|
int trimOffsetTop;
|
|
105
|
+
int trimMargin;
|
|
101
106
|
std::vector<double> linearA;
|
|
102
107
|
std::vector<double> linearB;
|
|
108
|
+
int dilateWidth;
|
|
109
|
+
int erodeWidth;
|
|
103
110
|
double gamma;
|
|
104
111
|
double gammaOut;
|
|
105
112
|
bool greyscale;
|
|
@@ -109,11 +116,11 @@ struct PipelineBaton {
|
|
|
109
116
|
int claheWidth;
|
|
110
117
|
int claheHeight;
|
|
111
118
|
int claheMaxSlope;
|
|
112
|
-
bool useExifOrientation;
|
|
113
119
|
int angle;
|
|
114
120
|
double rotationAngle;
|
|
115
121
|
std::vector<double> rotationBackground;
|
|
116
|
-
bool
|
|
122
|
+
bool rotateBefore;
|
|
123
|
+
bool orientBefore;
|
|
117
124
|
bool flip;
|
|
118
125
|
bool flop;
|
|
119
126
|
int extendTop;
|
|
@@ -157,19 +164,23 @@ struct PipelineBaton {
|
|
|
157
164
|
bool webpNearLossless;
|
|
158
165
|
bool webpLossless;
|
|
159
166
|
bool webpSmartSubsample;
|
|
167
|
+
bool webpSmartDeblock;
|
|
160
168
|
VipsForeignWebpPreset webpPreset;
|
|
161
169
|
int webpEffort;
|
|
162
170
|
bool webpMinSize;
|
|
163
171
|
bool webpMixed;
|
|
172
|
+
bool webpExact;
|
|
164
173
|
int gifBitdepth;
|
|
165
174
|
int gifEffort;
|
|
166
175
|
double gifDither;
|
|
167
176
|
double gifInterFrameMaxError;
|
|
168
177
|
double gifInterPaletteMaxError;
|
|
178
|
+
bool gifKeepDuplicateFrames;
|
|
169
179
|
bool gifReuse;
|
|
170
180
|
bool gifProgressive;
|
|
171
181
|
int tiffQuality;
|
|
172
182
|
VipsForeignTiffCompression tiffCompression;
|
|
183
|
+
bool tiffBigtiff;
|
|
173
184
|
VipsForeignTiffPredictor tiffPredictor;
|
|
174
185
|
bool tiffPyramid;
|
|
175
186
|
int tiffBitdepth;
|
|
@@ -186,18 +197,23 @@ struct PipelineBaton {
|
|
|
186
197
|
std::string heifChromaSubsampling;
|
|
187
198
|
bool heifLossless;
|
|
188
199
|
int heifBitdepth;
|
|
200
|
+
std::string heifTune;
|
|
189
201
|
double jxlDistance;
|
|
190
202
|
int jxlDecodingTier;
|
|
191
203
|
int jxlEffort;
|
|
192
204
|
bool jxlLossless;
|
|
193
205
|
VipsBandFormat rawDepth;
|
|
194
206
|
std::string err;
|
|
207
|
+
bool errUseWarning;
|
|
195
208
|
int keepMetadata;
|
|
196
209
|
int withMetadataOrientation;
|
|
197
210
|
double withMetadataDensity;
|
|
198
211
|
std::string withIccProfile;
|
|
199
212
|
std::unordered_map<std::string, std::string> withExif;
|
|
200
213
|
bool withExifMerge;
|
|
214
|
+
std::string withXmp;
|
|
215
|
+
bool withGainMap;
|
|
216
|
+
bool keepGainMap;
|
|
201
217
|
int timeoutSeconds;
|
|
202
218
|
std::vector<double> convKernel;
|
|
203
219
|
int convKernelWidth;
|
|
@@ -232,6 +248,7 @@ struct PipelineBaton {
|
|
|
232
248
|
bufferOutLength(0),
|
|
233
249
|
pageHeightOut(0),
|
|
234
250
|
pagesOut(0),
|
|
251
|
+
typedArrayOut(false),
|
|
235
252
|
topOffsetPre(-1),
|
|
236
253
|
topOffsetPost(-1),
|
|
237
254
|
channels(0),
|
|
@@ -271,8 +288,11 @@ struct PipelineBaton {
|
|
|
271
288
|
trimLineArt(false),
|
|
272
289
|
trimOffsetLeft(0),
|
|
273
290
|
trimOffsetTop(0),
|
|
291
|
+
trimMargin(0),
|
|
274
292
|
linearA{},
|
|
275
293
|
linearB{},
|
|
294
|
+
dilateWidth(0),
|
|
295
|
+
erodeWidth(0),
|
|
276
296
|
gamma(0.0),
|
|
277
297
|
greyscale(false),
|
|
278
298
|
normalise(false),
|
|
@@ -281,7 +301,6 @@ struct PipelineBaton {
|
|
|
281
301
|
claheWidth(0),
|
|
282
302
|
claheHeight(0),
|
|
283
303
|
claheMaxSlope(3),
|
|
284
|
-
useExifOrientation(false),
|
|
285
304
|
angle(0),
|
|
286
305
|
rotationAngle(0.0),
|
|
287
306
|
rotationBackground{ 0.0, 0.0, 0.0, 255.0 },
|
|
@@ -328,22 +347,26 @@ struct PipelineBaton {
|
|
|
328
347
|
webpNearLossless(false),
|
|
329
348
|
webpLossless(false),
|
|
330
349
|
webpSmartSubsample(false),
|
|
350
|
+
webpSmartDeblock(false),
|
|
331
351
|
webpPreset(VIPS_FOREIGN_WEBP_PRESET_DEFAULT),
|
|
332
352
|
webpEffort(4),
|
|
333
353
|
webpMinSize(false),
|
|
334
354
|
webpMixed(false),
|
|
355
|
+
webpExact(false),
|
|
335
356
|
gifBitdepth(8),
|
|
336
357
|
gifEffort(7),
|
|
337
358
|
gifDither(1.0),
|
|
338
359
|
gifInterFrameMaxError(0.0),
|
|
339
360
|
gifInterPaletteMaxError(3.0),
|
|
361
|
+
gifKeepDuplicateFrames(false),
|
|
340
362
|
gifReuse(true),
|
|
341
363
|
gifProgressive(false),
|
|
342
364
|
tiffQuality(80),
|
|
343
365
|
tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
|
|
366
|
+
tiffBigtiff(false),
|
|
344
367
|
tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
|
|
345
368
|
tiffPyramid(false),
|
|
346
|
-
tiffBitdepth(
|
|
369
|
+
tiffBitdepth(0),
|
|
347
370
|
tiffMiniswhite(false),
|
|
348
371
|
tiffTile(false),
|
|
349
372
|
tiffTileHeight(256),
|
|
@@ -357,15 +380,19 @@ struct PipelineBaton {
|
|
|
357
380
|
heifChromaSubsampling("4:4:4"),
|
|
358
381
|
heifLossless(false),
|
|
359
382
|
heifBitdepth(8),
|
|
383
|
+
heifTune("auto"),
|
|
360
384
|
jxlDistance(1.0),
|
|
361
385
|
jxlDecodingTier(0),
|
|
362
386
|
jxlEffort(7),
|
|
363
387
|
jxlLossless(false),
|
|
364
388
|
rawDepth(VIPS_FORMAT_UCHAR),
|
|
389
|
+
errUseWarning(false),
|
|
365
390
|
keepMetadata(0),
|
|
366
391
|
withMetadataOrientation(-1),
|
|
367
392
|
withMetadataDensity(0.0),
|
|
368
393
|
withExifMerge(true),
|
|
394
|
+
withGainMap(false),
|
|
395
|
+
keepGainMap(false),
|
|
369
396
|
timeoutSeconds(0),
|
|
370
397
|
convKernelWidth(0),
|
|
371
398
|
convKernelHeight(0),
|
package/src/sharp.cc
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
3
5
|
|
|
4
|
-
#include <mutex>
|
|
6
|
+
#include <mutex>
|
|
5
7
|
|
|
6
8
|
#include <napi.h>
|
|
7
9
|
#include <vips/vips8>
|
|
8
10
|
|
|
9
|
-
#include "common.h"
|
|
10
|
-
#include "metadata.h"
|
|
11
|
-
#include "pipeline.h"
|
|
12
|
-
#include "
|
|
13
|
-
#include "
|
|
11
|
+
#include "./common.h"
|
|
12
|
+
#include "./metadata.h"
|
|
13
|
+
#include "./pipeline.h"
|
|
14
|
+
#include "./stats.h"
|
|
15
|
+
#include "./utilities.h"
|
|
14
16
|
|
|
15
17
|
Napi::Object init(Napi::Env env, Napi::Object exports) {
|
|
16
18
|
static std::once_flag sharp_vips_init_once;
|
|
@@ -33,6 +35,7 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
|
|
|
33
35
|
exports.Set("block", Napi::Function::New(env, block));
|
|
34
36
|
exports.Set("_maxColourDistance", Napi::Function::New(env, _maxColourDistance));
|
|
35
37
|
exports.Set("_isUsingJemalloc", Napi::Function::New(env, _isUsingJemalloc));
|
|
38
|
+
exports.Set("_isUsingX64V2", Napi::Function::New(env, _isUsingX64V2));
|
|
36
39
|
exports.Set("stats", Napi::Function::New(env, stats));
|
|
37
40
|
return exports;
|
|
38
41
|
}
|
package/src/stats.cc
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
3
5
|
|
|
6
|
+
#include <iostream>
|
|
4
7
|
#include <numeric>
|
|
8
|
+
#include <string>
|
|
5
9
|
#include <vector>
|
|
6
|
-
#include <iostream>
|
|
7
10
|
|
|
8
11
|
#include <napi.h>
|
|
9
12
|
#include <vips/vips8>
|
|
10
13
|
|
|
11
|
-
#include "common.h"
|
|
12
|
-
#include "stats.h"
|
|
14
|
+
#include "./common.h"
|
|
15
|
+
#include "./stats.h"
|
|
13
16
|
|
|
14
17
|
class StatsWorker : public Napi::AsyncWorker {
|
|
15
18
|
public:
|
|
@@ -36,7 +39,7 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
36
39
|
sharp::ImageType imageType = sharp::ImageType::UNKNOWN;
|
|
37
40
|
try {
|
|
38
41
|
std::tie(image, imageType) = OpenInput(baton->input);
|
|
39
|
-
} catch (
|
|
42
|
+
} catch (std::runtime_error const &err) {
|
|
40
43
|
(baton->err).append(err.what());
|
|
41
44
|
}
|
|
42
45
|
if (imageType != sharp::ImageType::UNKNOWN) {
|
|
@@ -58,9 +61,9 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
58
61
|
baton->channelStats.push_back(cStats);
|
|
59
62
|
}
|
|
60
63
|
// Image is not opaque when alpha layer is present and contains a non-mamixa value
|
|
61
|
-
if (
|
|
64
|
+
if (image.has_alpha()) {
|
|
62
65
|
double const minAlpha = static_cast<double>(stats.getpoint(STAT_MIN_INDEX, bands).front());
|
|
63
|
-
if (minAlpha !=
|
|
66
|
+
if (minAlpha != vips_interpretation_max_alpha(image.interpretation())) {
|
|
64
67
|
baton->isOpaque = false;
|
|
65
68
|
}
|
|
66
69
|
}
|
|
@@ -89,7 +92,7 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
89
92
|
baton->dominantRed = dx * 16 + 8;
|
|
90
93
|
baton->dominantGreen = dy * 16 + 8;
|
|
91
94
|
baton->dominantBlue = dz * 16 + 8;
|
|
92
|
-
} catch (
|
|
95
|
+
} catch (std::runtime_error const &err) {
|
|
93
96
|
(baton->err).append(err.what());
|
|
94
97
|
}
|
|
95
98
|
}
|
|
@@ -106,10 +109,9 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
106
109
|
// Handle warnings
|
|
107
110
|
std::string warning = sharp::VipsWarningPop();
|
|
108
111
|
while (!warning.empty()) {
|
|
109
|
-
debuglog.
|
|
112
|
+
debuglog.SHARP_CALLBACK_FN_NAME(Receiver().Value(), { Napi::String::New(env, warning) });
|
|
110
113
|
warning = sharp::VipsWarningPop();
|
|
111
114
|
}
|
|
112
|
-
|
|
113
115
|
if (baton->err.empty()) {
|
|
114
116
|
// Stats Object
|
|
115
117
|
Napi::Object info = Napi::Object::New(env);
|
|
@@ -141,9 +143,10 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
141
143
|
dominant.Set("g", baton->dominantGreen);
|
|
142
144
|
dominant.Set("b", baton->dominantBlue);
|
|
143
145
|
info.Set("dominant", dominant);
|
|
144
|
-
Callback().
|
|
146
|
+
Callback().SHARP_CALLBACK_FN_NAME(Receiver().Value(), { env.Null(), info });
|
|
145
147
|
} else {
|
|
146
|
-
Callback().
|
|
148
|
+
Callback().SHARP_CALLBACK_FN_NAME(Receiver().Value(),
|
|
149
|
+
{ Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
|
|
147
150
|
}
|
|
148
151
|
|
|
149
152
|
delete baton->input;
|
package/src/stats.h
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
3
5
|
|
|
4
6
|
#ifndef SRC_STATS_H_
|
|
5
7
|
#define SRC_STATS_H_
|
|
6
8
|
|
|
7
9
|
#include <string>
|
|
10
|
+
#include <vector>
|
|
8
11
|
#include <napi.h>
|
|
9
12
|
|
|
10
13
|
#include "./common.h"
|
|
@@ -24,7 +27,7 @@ struct ChannelStats {
|
|
|
24
27
|
|
|
25
28
|
ChannelStats(int minVal, int maxVal, double sumVal, double squaresSumVal,
|
|
26
29
|
double meanVal, double stdevVal, int minXVal, int minYVal, int maxXVal, int maxYVal):
|
|
27
|
-
min(minVal), max(maxVal), sum(sumVal), squaresSum(squaresSumVal),
|
|
30
|
+
min(minVal), max(maxVal), sum(sumVal), squaresSum(squaresSumVal), // NOLINT(build/include_what_you_use)
|
|
28
31
|
mean(meanVal), stdev(stdevVal), minX(minXVal), minY(minYVal), maxX(maxXVal), maxY(maxYVal) {}
|
|
29
32
|
};
|
|
30
33
|
|
package/src/utilities.cc
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
3
5
|
|
|
4
6
|
#include <cmath>
|
|
5
|
-
#include <string>
|
|
6
7
|
#include <cstdio>
|
|
8
|
+
#include <string>
|
|
7
9
|
|
|
8
10
|
#include <napi.h>
|
|
9
11
|
#include <vips/vips8>
|
|
10
12
|
#include <vips/vector.h>
|
|
11
13
|
|
|
12
|
-
#include "common.h"
|
|
13
|
-
#include "operations.h"
|
|
14
|
-
#include "utilities.h"
|
|
14
|
+
#include "./common.h"
|
|
15
|
+
#include "./operations.h"
|
|
16
|
+
#include "./utilities.h"
|
|
15
17
|
|
|
16
18
|
/*
|
|
17
19
|
Get and set cache limits
|
|
@@ -119,8 +121,9 @@ Napi::Value format(const Napi::CallbackInfo& info) {
|
|
|
119
121
|
Napi::Object format = Napi::Object::New(env);
|
|
120
122
|
for (std::string const f : {
|
|
121
123
|
"jpeg", "png", "webp", "tiff", "magick", "openslide", "dz",
|
|
122
|
-
"ppm", "fits", "gif", "svg", "heif", "pdf", "vips", "jp2k", "jxl"
|
|
124
|
+
"ppm", "fits", "gif", "svg", "heif", "pdf", "vips", "jp2k", "jxl", "rad", "dcraw"
|
|
123
125
|
}) {
|
|
126
|
+
std::string id = f == "jp2k" ? "jp2" : f;
|
|
124
127
|
// Input
|
|
125
128
|
const VipsObjectClass *oc = vips_class_find("VipsOperation", (f + "load").c_str());
|
|
126
129
|
Napi::Boolean hasInputFile = Napi::Boolean::New(env, oc);
|
|
@@ -152,11 +155,11 @@ Napi::Value format(const Napi::CallbackInfo& info) {
|
|
|
152
155
|
output.Set("stream", hasOutputBuffer);
|
|
153
156
|
// Other attributes
|
|
154
157
|
Napi::Object container = Napi::Object::New(env);
|
|
155
|
-
container.Set("id",
|
|
158
|
+
container.Set("id", id);
|
|
156
159
|
container.Set("input", input);
|
|
157
160
|
container.Set("output", output);
|
|
158
161
|
// Add to set of formats
|
|
159
|
-
format.Set(
|
|
162
|
+
format.Set(id, container);
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
// Raw, uncompressed data
|
|
@@ -233,15 +236,15 @@ Napi::Value _maxColourDistance(const Napi::CallbackInfo& info) {
|
|
|
233
236
|
double maxColourDistance;
|
|
234
237
|
try {
|
|
235
238
|
// Premultiply and remove alpha
|
|
236
|
-
if (
|
|
239
|
+
if (image1.has_alpha()) {
|
|
237
240
|
image1 = image1.premultiply().extract_band(1, VImage::option()->set("n", image1.bands() - 1));
|
|
238
241
|
}
|
|
239
|
-
if (
|
|
242
|
+
if (image2.has_alpha()) {
|
|
240
243
|
image2 = image2.premultiply().extract_band(1, VImage::option()->set("n", image2.bands() - 1));
|
|
241
244
|
}
|
|
242
245
|
// Calculate colour distance
|
|
243
246
|
maxColourDistance = image1.dE00(image2).max();
|
|
244
|
-
} catch (
|
|
247
|
+
} catch (std::runtime_error const &err) {
|
|
245
248
|
throw Napi::Error::New(env, err.what());
|
|
246
249
|
}
|
|
247
250
|
|
|
@@ -267,3 +270,20 @@ Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
|
|
|
267
270
|
return Napi::Boolean::New(env, false);
|
|
268
271
|
}
|
|
269
272
|
#endif
|
|
273
|
+
|
|
274
|
+
#if defined(__GNUC__) && defined(__x86_64__)
|
|
275
|
+
// Are SSE 4.2 intrinsics available at runtime?
|
|
276
|
+
Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info) {
|
|
277
|
+
Napi::Env env = info.Env();
|
|
278
|
+
unsigned int eax, ebx, ecx, edx;
|
|
279
|
+
__asm__ __volatile__("cpuid"
|
|
280
|
+
: "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
|
|
281
|
+
: "a"(1));
|
|
282
|
+
return Napi::Boolean::New(env, (ecx & 1U << 20) != 0);
|
|
283
|
+
}
|
|
284
|
+
#else
|
|
285
|
+
Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info) {
|
|
286
|
+
Napi::Env env = info.Env();
|
|
287
|
+
return Napi::Boolean::New(env, false);
|
|
288
|
+
}
|
|
289
|
+
#endif
|
package/src/utilities.h
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
3
5
|
|
|
4
6
|
#ifndef SRC_UTILITIES_H_
|
|
5
7
|
#define SRC_UTILITIES_H_
|
|
@@ -15,5 +17,6 @@ Napi::Value format(const Napi::CallbackInfo& info);
|
|
|
15
17
|
void block(const Napi::CallbackInfo& info);
|
|
16
18
|
Napi::Value _maxColourDistance(const Napi::CallbackInfo& info);
|
|
17
19
|
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info);
|
|
20
|
+
Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info);
|
|
18
21
|
|
|
19
22
|
#endif // SRC_UTILITIES_H_
|
package/install/check.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Copyright 2013 Lovell Fuller and others.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
const { useGlobalLibvips, globalLibvipsVersion, log, spawnRebuild } = require('../lib/libvips');
|
|
8
|
-
|
|
9
|
-
const buildFromSource = (msg) => {
|
|
10
|
-
log(msg);
|
|
11
|
-
log('Attempting to build from source via node-gyp');
|
|
12
|
-
try {
|
|
13
|
-
const addonApi = require('node-addon-api');
|
|
14
|
-
log(`Found node-addon-api ${addonApi.version || ''}`);
|
|
15
|
-
} catch (err) {
|
|
16
|
-
log('Please add node-addon-api to your dependencies');
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const gyp = require('node-gyp');
|
|
21
|
-
log(`Found node-gyp ${gyp().version}`);
|
|
22
|
-
} catch (err) {
|
|
23
|
-
log('Please add node-gyp to your dependencies');
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
log('See https://sharp.pixelplumbing.com/install#building-from-source');
|
|
27
|
-
const status = spawnRebuild();
|
|
28
|
-
if (status !== 0) {
|
|
29
|
-
process.exit(status);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
if (useGlobalLibvips(log)) {
|
|
34
|
-
buildFromSource(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
|
|
35
|
-
} else if (process.env.npm_config_build_from_source) {
|
|
36
|
-
buildFromSource('Detected --build-from-source flag');
|
|
37
|
-
}
|
|
38
|
-
} catch (err) {
|
|
39
|
-
const summary = err.message.split(/\n/).slice(0, 1);
|
|
40
|
-
console.log(`sharp: skipping install check: ${summary}`);
|
|
41
|
-
}
|
package/lib/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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;
|
package/lib/sharp.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// Copyright 2013 Lovell Fuller and others.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
// Inspects the runtime environment and exports the relevant sharp.node binary
|
|
7
|
-
|
|
8
|
-
const { familySync, versionSync } = require('detect-libc');
|
|
9
|
-
|
|
10
|
-
const { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');
|
|
11
|
-
const runtimePlatform = runtimePlatformArch();
|
|
12
|
-
|
|
13
|
-
const paths = [
|
|
14
|
-
`../src/build/Release/sharp-${runtimePlatform}.node`,
|
|
15
|
-
'../src/build/Release/sharp-wasm32.node',
|
|
16
|
-
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
17
|
-
'@img/sharp-wasm32/sharp.node'
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
let sharp;
|
|
21
|
-
const errors = [];
|
|
22
|
-
for (const path of paths) {
|
|
23
|
-
try {
|
|
24
|
-
sharp = require(path);
|
|
25
|
-
break;
|
|
26
|
-
} catch (err) {
|
|
27
|
-
/* istanbul ignore next */
|
|
28
|
-
errors.push(err);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/* istanbul ignore next */
|
|
33
|
-
if (sharp) {
|
|
34
|
-
module.exports = sharp;
|
|
35
|
-
} else {
|
|
36
|
-
const [isLinux, isMacOs, isWindows] = ['linux', 'darwin', 'win32'].map(os => runtimePlatform.startsWith(os));
|
|
37
|
-
|
|
38
|
-
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
39
|
-
errors.forEach(err => {
|
|
40
|
-
if (err.code !== 'MODULE_NOT_FOUND') {
|
|
41
|
-
help.push(`${err.code}: ${err.message}`);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const messages = errors.map(err => err.message).join(' ');
|
|
45
|
-
help.push('Possible solutions:');
|
|
46
|
-
// Common error messages
|
|
47
|
-
if (isUnsupportedNodeRuntime()) {
|
|
48
|
-
const { found, expected } = isUnsupportedNodeRuntime();
|
|
49
|
-
help.push(
|
|
50
|
-
'- Please upgrade Node.js:',
|
|
51
|
-
` Found ${found}`,
|
|
52
|
-
` Requires ${expected}`
|
|
53
|
-
);
|
|
54
|
-
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
55
|
-
const [os, cpu] = runtimePlatform.split('-');
|
|
56
|
-
const libc = os.endsWith('musl') ? ' --libc=musl' : '';
|
|
57
|
-
help.push(
|
|
58
|
-
'- Ensure optional dependencies can be installed:',
|
|
59
|
-
' npm install --include=optional sharp',
|
|
60
|
-
'- Ensure your package manager supports multi-platform installation:',
|
|
61
|
-
' See https://sharp.pixelplumbing.com/install#cross-platform',
|
|
62
|
-
'- Add platform-specific dependencies:',
|
|
63
|
-
` npm install --os=${os.replace('musl', '')}${libc} --cpu=${cpu} sharp`
|
|
64
|
-
);
|
|
65
|
-
} else {
|
|
66
|
-
help.push(
|
|
67
|
-
`- Manually install libvips >= ${minimumLibvipsVersion}`,
|
|
68
|
-
'- Add experimental WebAssembly-based dependencies:',
|
|
69
|
-
' npm install --cpu=wasm32 sharp',
|
|
70
|
-
' npm install @img/sharp-wasm32'
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {
|
|
74
|
-
try {
|
|
75
|
-
const { config } = require(`@img/sharp-libvips-${runtimePlatform}/package`);
|
|
76
|
-
const libcFound = `${familySync()} ${versionSync()}`;
|
|
77
|
-
const libcRequires = `${config.musl ? 'musl' : 'glibc'} ${config.musl || config.glibc}`;
|
|
78
|
-
help.push(
|
|
79
|
-
'- Update your OS:',
|
|
80
|
-
` Found ${libcFound}`,
|
|
81
|
-
` Requires ${libcRequires}`
|
|
82
|
-
);
|
|
83
|
-
} catch (errEngines) {}
|
|
84
|
-
}
|
|
85
|
-
if (isLinux && /\/snap\/core[0-9]{2}/.test(messages)) {
|
|
86
|
-
help.push(
|
|
87
|
-
'- Remove the Node.js Snap, which does not support native modules',
|
|
88
|
-
' snap remove node'
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
if (isMacOs && /Incompatible library version/.test(messages)) {
|
|
92
|
-
help.push(
|
|
93
|
-
'- Update Homebrew:',
|
|
94
|
-
' brew update && brew upgrade vips'
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
if (errors.some(err => err.code === 'ERR_DLOPEN_DISABLED')) {
|
|
98
|
-
help.push('- Run Node.js without using the --no-addons flag');
|
|
99
|
-
}
|
|
100
|
-
// Link to installation docs
|
|
101
|
-
if (isWindows && /The specified procedure could not be found/.test(messages)) {
|
|
102
|
-
help.push(
|
|
103
|
-
'- Using the canvas package on Windows?',
|
|
104
|
-
' See https://sharp.pixelplumbing.com/install#canvas-and-windows',
|
|
105
|
-
'- Check for outdated versions of sharp in the dependency tree:',
|
|
106
|
-
' npm ls sharp'
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
help.push(
|
|
110
|
-
'- Consult the installation documentation:',
|
|
111
|
-
' See https://sharp.pixelplumbing.com/install'
|
|
112
|
-
);
|
|
113
|
-
throw new Error(help.join('\n'));
|
|
114
|
-
}
|