sharp 0.34.5 → 0.35.0-rc.2
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 +7 -17
- package/install/build.js +2 -2
- package/lib/constructor.js +8 -2
- package/lib/index.d.ts +60 -62
- package/lib/input.js +4 -10
- package/lib/libvips.js +27 -19
- package/lib/operation.js +4 -33
- package/lib/output.js +141 -8
- package/lib/resize.js +16 -0
- package/lib/sharp.js +62 -20
- package/lib/utility.js +1 -1
- package/package.json +46 -45
- package/src/binding.gyp +11 -6
- package/src/common.cc +64 -14
- package/src/common.h +21 -4
- package/src/metadata.cc +66 -8
- package/src/metadata.h +6 -1
- package/src/operations.cc +25 -8
- package/src/operations.h +1 -1
- package/src/pipeline.cc +186 -51
- package/src/pipeline.h +13 -1
- package/src/stats.cc +6 -6
- package/src/utilities.cc +4 -3
- package/install/check.js +0 -14
package/src/pipeline.h
CHANGED
|
@@ -48,6 +48,7 @@ struct PipelineBaton {
|
|
|
48
48
|
size_t bufferOutLength;
|
|
49
49
|
int pageHeightOut;
|
|
50
50
|
int pagesOut;
|
|
51
|
+
bool typedArrayOut;
|
|
51
52
|
std::vector<Composite *> composite;
|
|
52
53
|
std::vector<sharp::InputDescriptor *> joinChannelIn;
|
|
53
54
|
int topOffsetPre;
|
|
@@ -101,6 +102,7 @@ struct PipelineBaton {
|
|
|
101
102
|
bool trimLineArt;
|
|
102
103
|
int trimOffsetLeft;
|
|
103
104
|
int trimOffsetTop;
|
|
105
|
+
int trimMargin;
|
|
104
106
|
std::vector<double> linearA;
|
|
105
107
|
std::vector<double> linearB;
|
|
106
108
|
int dilateWidth;
|
|
@@ -167,6 +169,7 @@ struct PipelineBaton {
|
|
|
167
169
|
int webpEffort;
|
|
168
170
|
bool webpMinSize;
|
|
169
171
|
bool webpMixed;
|
|
172
|
+
bool webpExact;
|
|
170
173
|
int gifBitdepth;
|
|
171
174
|
int gifEffort;
|
|
172
175
|
double gifDither;
|
|
@@ -194,6 +197,7 @@ struct PipelineBaton {
|
|
|
194
197
|
std::string heifChromaSubsampling;
|
|
195
198
|
bool heifLossless;
|
|
196
199
|
int heifBitdepth;
|
|
200
|
+
std::string heifTune;
|
|
197
201
|
double jxlDistance;
|
|
198
202
|
int jxlDecodingTier;
|
|
199
203
|
int jxlEffort;
|
|
@@ -208,6 +212,8 @@ struct PipelineBaton {
|
|
|
208
212
|
std::unordered_map<std::string, std::string> withExif;
|
|
209
213
|
bool withExifMerge;
|
|
210
214
|
std::string withXmp;
|
|
215
|
+
bool withGainMap;
|
|
216
|
+
bool keepGainMap;
|
|
211
217
|
int timeoutSeconds;
|
|
212
218
|
std::vector<double> convKernel;
|
|
213
219
|
int convKernelWidth;
|
|
@@ -242,6 +248,7 @@ struct PipelineBaton {
|
|
|
242
248
|
bufferOutLength(0),
|
|
243
249
|
pageHeightOut(0),
|
|
244
250
|
pagesOut(0),
|
|
251
|
+
typedArrayOut(false),
|
|
245
252
|
topOffsetPre(-1),
|
|
246
253
|
topOffsetPost(-1),
|
|
247
254
|
channels(0),
|
|
@@ -281,6 +288,7 @@ struct PipelineBaton {
|
|
|
281
288
|
trimLineArt(false),
|
|
282
289
|
trimOffsetLeft(0),
|
|
283
290
|
trimOffsetTop(0),
|
|
291
|
+
trimMargin(0),
|
|
284
292
|
linearA{},
|
|
285
293
|
linearB{},
|
|
286
294
|
dilateWidth(0),
|
|
@@ -344,6 +352,7 @@ struct PipelineBaton {
|
|
|
344
352
|
webpEffort(4),
|
|
345
353
|
webpMinSize(false),
|
|
346
354
|
webpMixed(false),
|
|
355
|
+
webpExact(false),
|
|
347
356
|
gifBitdepth(8),
|
|
348
357
|
gifEffort(7),
|
|
349
358
|
gifDither(1.0),
|
|
@@ -357,7 +366,7 @@ struct PipelineBaton {
|
|
|
357
366
|
tiffBigtiff(false),
|
|
358
367
|
tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
|
|
359
368
|
tiffPyramid(false),
|
|
360
|
-
tiffBitdepth(
|
|
369
|
+
tiffBitdepth(0),
|
|
361
370
|
tiffMiniswhite(false),
|
|
362
371
|
tiffTile(false),
|
|
363
372
|
tiffTileHeight(256),
|
|
@@ -371,6 +380,7 @@ struct PipelineBaton {
|
|
|
371
380
|
heifChromaSubsampling("4:4:4"),
|
|
372
381
|
heifLossless(false),
|
|
373
382
|
heifBitdepth(8),
|
|
383
|
+
heifTune("ssim"),
|
|
374
384
|
jxlDistance(1.0),
|
|
375
385
|
jxlDecodingTier(0),
|
|
376
386
|
jxlEffort(7),
|
|
@@ -381,6 +391,8 @@ struct PipelineBaton {
|
|
|
381
391
|
withMetadataOrientation(-1),
|
|
382
392
|
withMetadataDensity(0.0),
|
|
383
393
|
withExifMerge(true),
|
|
394
|
+
withGainMap(false),
|
|
395
|
+
keepGainMap(false),
|
|
384
396
|
timeoutSeconds(0),
|
|
385
397
|
convKernelWidth(0),
|
|
386
398
|
convKernelHeight(0),
|
package/src/stats.cc
CHANGED
|
@@ -39,7 +39,7 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
39
39
|
sharp::ImageType imageType = sharp::ImageType::UNKNOWN;
|
|
40
40
|
try {
|
|
41
41
|
std::tie(image, imageType) = OpenInput(baton->input);
|
|
42
|
-
} catch (
|
|
42
|
+
} catch (std::runtime_error const &err) {
|
|
43
43
|
(baton->err).append(err.what());
|
|
44
44
|
}
|
|
45
45
|
if (imageType != sharp::ImageType::UNKNOWN) {
|
|
@@ -92,7 +92,7 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
92
92
|
baton->dominantRed = dx * 16 + 8;
|
|
93
93
|
baton->dominantGreen = dy * 16 + 8;
|
|
94
94
|
baton->dominantBlue = dz * 16 + 8;
|
|
95
|
-
} catch (
|
|
95
|
+
} catch (std::runtime_error const &err) {
|
|
96
96
|
(baton->err).append(err.what());
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -109,10 +109,9 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
109
109
|
// Handle warnings
|
|
110
110
|
std::string warning = sharp::VipsWarningPop();
|
|
111
111
|
while (!warning.empty()) {
|
|
112
|
-
debuglog.
|
|
112
|
+
debuglog.SHARP_CALLBACK_FN_NAME(Receiver().Value(), { Napi::String::New(env, warning) });
|
|
113
113
|
warning = sharp::VipsWarningPop();
|
|
114
114
|
}
|
|
115
|
-
|
|
116
115
|
if (baton->err.empty()) {
|
|
117
116
|
// Stats Object
|
|
118
117
|
Napi::Object info = Napi::Object::New(env);
|
|
@@ -144,9 +143,10 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
144
143
|
dominant.Set("g", baton->dominantGreen);
|
|
145
144
|
dominant.Set("b", baton->dominantBlue);
|
|
146
145
|
info.Set("dominant", dominant);
|
|
147
|
-
Callback().
|
|
146
|
+
Callback().SHARP_CALLBACK_FN_NAME(Receiver().Value(), { env.Null(), info });
|
|
148
147
|
} else {
|
|
149
|
-
Callback().
|
|
148
|
+
Callback().SHARP_CALLBACK_FN_NAME(Receiver().Value(),
|
|
149
|
+
{ Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
delete baton->input;
|
package/src/utilities.cc
CHANGED
|
@@ -123,6 +123,7 @@ Napi::Value format(const Napi::CallbackInfo& info) {
|
|
|
123
123
|
"jpeg", "png", "webp", "tiff", "magick", "openslide", "dz",
|
|
124
124
|
"ppm", "fits", "gif", "svg", "heif", "pdf", "vips", "jp2k", "jxl", "rad", "dcraw"
|
|
125
125
|
}) {
|
|
126
|
+
std::string id = f == "jp2k" ? "jp2" : f;
|
|
126
127
|
// Input
|
|
127
128
|
const VipsObjectClass *oc = vips_class_find("VipsOperation", (f + "load").c_str());
|
|
128
129
|
Napi::Boolean hasInputFile = Napi::Boolean::New(env, oc);
|
|
@@ -154,11 +155,11 @@ Napi::Value format(const Napi::CallbackInfo& info) {
|
|
|
154
155
|
output.Set("stream", hasOutputBuffer);
|
|
155
156
|
// Other attributes
|
|
156
157
|
Napi::Object container = Napi::Object::New(env);
|
|
157
|
-
container.Set("id",
|
|
158
|
+
container.Set("id", id);
|
|
158
159
|
container.Set("input", input);
|
|
159
160
|
container.Set("output", output);
|
|
160
161
|
// Add to set of formats
|
|
161
|
-
format.Set(
|
|
162
|
+
format.Set(id, container);
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
// Raw, uncompressed data
|
|
@@ -243,7 +244,7 @@ Napi::Value _maxColourDistance(const Napi::CallbackInfo& info) {
|
|
|
243
244
|
}
|
|
244
245
|
// Calculate colour distance
|
|
245
246
|
maxColourDistance = image1.dE00(image2).max();
|
|
246
|
-
} catch (
|
|
247
|
+
} catch (std::runtime_error const &err) {
|
|
247
248
|
throw Napi::Error::New(env, err.what());
|
|
248
249
|
}
|
|
249
250
|
|
package/install/check.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
Copyright 2013 Lovell Fuller and others.
|
|
3
|
-
SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
const { useGlobalLibvips } = require('../lib/libvips');
|
|
8
|
-
if (useGlobalLibvips() || process.env.npm_config_build_from_source) {
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
11
|
-
} catch (err) {
|
|
12
|
-
const summary = err.message.split(/\n/).slice(0, 1);
|
|
13
|
-
console.log(`sharp: skipping install check: ${summary}`);
|
|
14
|
-
}
|