sharp 0.27.1 → 0.30.5

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/src/pipeline.h CHANGED
@@ -18,6 +18,7 @@
18
18
  #include <memory>
19
19
  #include <string>
20
20
  #include <vector>
21
+ #include <unordered_map>
21
22
 
22
23
  #include <napi.h>
23
24
  #include <vips/vips8>
@@ -26,14 +27,6 @@
26
27
 
27
28
  Napi::Value pipeline(const Napi::CallbackInfo& info);
28
29
 
29
- enum class Canvas {
30
- CROP,
31
- EMBED,
32
- MAX,
33
- MIN,
34
- IGNORE_ASPECT
35
- };
36
-
37
30
  struct Composite {
38
31
  sharp::InputDescriptor *input;
39
32
  VipsBlendMode mode;
@@ -74,7 +67,7 @@ struct PipelineBaton {
74
67
  int width;
75
68
  int height;
76
69
  int channels;
77
- Canvas canvas;
70
+ sharp::Canvas canvas;
78
71
  int position;
79
72
  std::vector<double> resizeBackground;
80
73
  bool hasCropOffset;
@@ -89,14 +82,19 @@ struct PipelineBaton {
89
82
  bool flatten;
90
83
  std::vector<double> flattenBackground;
91
84
  bool negate;
85
+ bool negateAlpha;
92
86
  double blurSigma;
93
87
  double brightness;
94
88
  double saturation;
95
89
  int hue;
90
+ double lightness;
96
91
  int medianSize;
97
92
  double sharpenSigma;
98
- double sharpenFlat;
99
- double sharpenJagged;
93
+ double sharpenM1;
94
+ double sharpenM2;
95
+ double sharpenX1;
96
+ double sharpenY2;
97
+ double sharpenY3;
100
98
  int threshold;
101
99
  bool thresholdGrayscale;
102
100
  double trimThreshold;
@@ -108,6 +106,9 @@ struct PipelineBaton {
108
106
  double gammaOut;
109
107
  bool greyscale;
110
108
  bool normalise;
109
+ int claheWidth;
110
+ int claheHeight;
111
+ int claheMaxSlope;
111
112
  bool useExifOrientation;
112
113
  int angle;
113
114
  double rotationAngle;
@@ -121,13 +122,14 @@ struct PipelineBaton {
121
122
  int extendRight;
122
123
  std::vector<double> extendBackground;
123
124
  bool withoutEnlargement;
125
+ bool withoutReduction;
124
126
  std::vector<double> affineMatrix;
125
127
  std::vector<double> affineBackground;
126
128
  double affineIdx;
127
129
  double affineIdy;
128
130
  double affineOdx;
129
131
  double affineOdy;
130
- vips::VInterpolate affineInterpolator;
132
+ std::string affineInterpolator;
131
133
  int jpegQuality;
132
134
  bool jpegProgressive;
133
135
  std::string jpegChromaSubsampling;
@@ -141,14 +143,23 @@ struct PipelineBaton {
141
143
  bool pngAdaptiveFiltering;
142
144
  bool pngPalette;
143
145
  int pngQuality;
144
- int pngColours;
146
+ int pngEffort;
147
+ int pngBitdepth;
145
148
  double pngDither;
149
+ int jp2Quality;
150
+ bool jp2Lossless;
151
+ int jp2TileHeight;
152
+ int jp2TileWidth;
153
+ std::string jp2ChromaSubsampling;
146
154
  int webpQuality;
147
155
  int webpAlphaQuality;
148
156
  bool webpNearLossless;
149
157
  bool webpLossless;
150
158
  bool webpSmartSubsample;
151
- int webpReductionEffort;
159
+ int webpEffort;
160
+ int gifBitdepth;
161
+ int gifEffort;
162
+ double gifDither;
152
163
  int tiffQuality;
153
164
  VipsForeignTiffCompression tiffCompression;
154
165
  VipsForeignTiffPredictor tiffPredictor;
@@ -159,15 +170,20 @@ struct PipelineBaton {
159
170
  int tiffTileWidth;
160
171
  double tiffXres;
161
172
  double tiffYres;
173
+ VipsForeignTiffResunit tiffResolutionUnit;
162
174
  int heifQuality;
163
175
  VipsForeignHeifCompression heifCompression;
164
- int heifSpeed;
176
+ int heifEffort;
165
177
  std::string heifChromaSubsampling;
166
178
  bool heifLossless;
179
+ VipsBandFormat rawDepth;
167
180
  std::string err;
168
181
  bool withMetadata;
169
182
  int withMetadataOrientation;
183
+ double withMetadataDensity;
170
184
  std::string withMetadataIcc;
185
+ std::unordered_map<std::string, std::string> withMetadataStrs;
186
+ int timeoutSeconds;
171
187
  std::unique_ptr<double[]> convKernel;
172
188
  int convKernelWidth;
173
189
  int convKernelHeight;
@@ -178,9 +194,9 @@ struct PipelineBaton {
178
194
  VipsOperationBoolean bandBoolOp;
179
195
  int extractChannel;
180
196
  bool removeAlpha;
181
- bool ensureAlpha;
197
+ double ensureAlpha;
198
+ VipsInterpretation colourspaceInput;
182
199
  VipsInterpretation colourspace;
183
- int pageHeight;
184
200
  std::vector<int> delay;
185
201
  int loop;
186
202
  int tileSize;
@@ -192,6 +208,7 @@ struct PipelineBaton {
192
208
  std::vector<double> tileBackground;
193
209
  int tileSkipBlanks;
194
210
  VipsForeignDzDepth tileDepth;
211
+ std::string tileId;
195
212
  std::unique_ptr<double[]> recombMatrix;
196
213
 
197
214
  PipelineBaton():
@@ -200,7 +217,7 @@ struct PipelineBaton {
200
217
  topOffsetPre(-1),
201
218
  topOffsetPost(-1),
202
219
  channels(0),
203
- canvas(Canvas::CROP),
220
+ canvas(sharp::Canvas::CROP),
204
221
  position(0),
205
222
  resizeBackground{ 0.0, 0.0, 0.0, 255.0 },
206
223
  hasCropOffset(false),
@@ -212,14 +229,19 @@ struct PipelineBaton {
212
229
  flatten(false),
213
230
  flattenBackground{ 0.0, 0.0, 0.0 },
214
231
  negate(false),
232
+ negateAlpha(true),
215
233
  blurSigma(0.0),
216
234
  brightness(1.0),
217
235
  saturation(1.0),
218
236
  hue(0),
237
+ lightness(0),
219
238
  medianSize(0),
220
239
  sharpenSigma(0.0),
221
- sharpenFlat(1.0),
222
- sharpenJagged(2.0),
240
+ sharpenM1(1.0),
241
+ sharpenM2(2.0),
242
+ sharpenX1(2.0),
243
+ sharpenY2(10.0),
244
+ sharpenY3(20.0),
223
245
  threshold(0),
224
246
  thresholdGrayscale(true),
225
247
  trimThreshold(0.0),
@@ -230,6 +252,9 @@ struct PipelineBaton {
230
252
  gamma(0.0),
231
253
  greyscale(false),
232
254
  normalise(false),
255
+ claheWidth(0),
256
+ claheHeight(0),
257
+ claheMaxSlope(3),
233
258
  useExifOrientation(false),
234
259
  angle(0),
235
260
  rotationAngle(0.0),
@@ -242,13 +267,14 @@ struct PipelineBaton {
242
267
  extendRight(0),
243
268
  extendBackground{ 0.0, 0.0, 0.0, 255.0 },
244
269
  withoutEnlargement(false),
270
+ withoutReduction(false),
245
271
  affineMatrix{ 1.0, 0.0, 0.0, 1.0 },
246
272
  affineBackground{ 0.0, 0.0, 0.0, 255.0 },
247
273
  affineIdx(0),
248
274
  affineIdy(0),
249
275
  affineOdx(0),
250
276
  affineOdy(0),
251
- affineInterpolator(vips::VInterpolate::new_from_name("bicubic")),
277
+ affineInterpolator("bicubic"),
252
278
  jpegQuality(80),
253
279
  jpegProgressive(false),
254
280
  jpegChromaSubsampling("4:2:0"),
@@ -258,18 +284,24 @@ struct PipelineBaton {
258
284
  jpegOptimiseScans(false),
259
285
  jpegOptimiseCoding(true),
260
286
  pngProgressive(false),
261
- pngCompressionLevel(9),
287
+ pngCompressionLevel(6),
262
288
  pngAdaptiveFiltering(false),
263
289
  pngPalette(false),
264
290
  pngQuality(100),
265
- pngColours(256),
291
+ pngEffort(7),
292
+ pngBitdepth(8),
266
293
  pngDither(1.0),
294
+ jp2Quality(80),
295
+ jp2Lossless(false),
296
+ jp2TileHeight(512),
297
+ jp2TileWidth(512),
298
+ jp2ChromaSubsampling("4:4:4"),
267
299
  webpQuality(80),
268
300
  webpAlphaQuality(100),
269
301
  webpNearLossless(false),
270
302
  webpLossless(false),
271
303
  webpSmartSubsample(false),
272
- webpReductionEffort(4),
304
+ webpEffort(4),
273
305
  tiffQuality(80),
274
306
  tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
275
307
  tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
@@ -280,13 +312,17 @@ struct PipelineBaton {
280
312
  tiffTileWidth(256),
281
313
  tiffXres(1.0),
282
314
  tiffYres(1.0),
315
+ tiffResolutionUnit(VIPS_FOREIGN_TIFF_RESUNIT_INCH),
283
316
  heifQuality(50),
284
317
  heifCompression(VIPS_FOREIGN_HEIF_COMPRESSION_AV1),
285
- heifSpeed(5),
286
- heifChromaSubsampling("4:2:0"),
318
+ heifEffort(4),
319
+ heifChromaSubsampling("4:4:4"),
287
320
  heifLossless(false),
321
+ rawDepth(VIPS_FORMAT_UCHAR),
288
322
  withMetadata(false),
289
323
  withMetadataOrientation(-1),
324
+ withMetadataDensity(0.0),
325
+ timeoutSeconds(0),
290
326
  convKernelWidth(0),
291
327
  convKernelHeight(0),
292
328
  convKernelScale(0.0),
@@ -296,10 +332,9 @@ struct PipelineBaton {
296
332
  bandBoolOp(VIPS_OPERATION_BOOLEAN_LAST),
297
333
  extractChannel(-1),
298
334
  removeAlpha(false),
299
- ensureAlpha(false),
335
+ ensureAlpha(-1.0),
336
+ colourspaceInput(VIPS_INTERPRETATION_LAST),
300
337
  colourspace(VIPS_INTERPRETATION_LAST),
301
- pageHeight(0),
302
- delay{-1},
303
338
  loop(-1),
304
339
  tileSize(256),
305
340
  tileOverlap(0),
package/src/sharp.cc CHANGED
@@ -44,6 +44,7 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
44
44
  exports.Set("libvipsVersion", Napi::Function::New(env, libvipsVersion));
45
45
  exports.Set("format", Napi::Function::New(env, format));
46
46
  exports.Set("_maxColourDistance", Napi::Function::New(env, _maxColourDistance));
47
+ exports.Set("_isUsingJemalloc", Napi::Function::New(env, _isUsingJemalloc));
47
48
  exports.Set("stats", Napi::Function::New(env, stats));
48
49
  return exports;
49
50
  }
package/src/utilities.cc CHANGED
@@ -115,7 +115,7 @@ Napi::Value format(const Napi::CallbackInfo& info) {
115
115
  Napi::Object format = Napi::Object::New(env);
116
116
  for (std::string const f : {
117
117
  "jpeg", "png", "webp", "tiff", "magick", "openslide", "dz",
118
- "ppm", "fits", "gif", "svg", "heif", "pdf", "vips"
118
+ "ppm", "fits", "gif", "svg", "heif", "pdf", "vips", "jp2k"
119
119
  }) {
120
120
  // Input
121
121
  Napi::Boolean hasInputFile =
@@ -225,3 +225,19 @@ Napi::Value _maxColourDistance(const Napi::CallbackInfo& info) {
225
225
 
226
226
  return Napi::Number::New(env, maxColourDistance);
227
227
  }
228
+
229
+ #if defined(__GNUC__)
230
+ // mallctl will be resolved by the runtime linker when jemalloc is being used
231
+ extern "C" {
232
+ int mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) __attribute__((weak));
233
+ }
234
+ Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
235
+ Napi::Env env = info.Env();
236
+ return Napi::Boolean::New(env, mallctl != nullptr);
237
+ }
238
+ #else
239
+ Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
240
+ Napi::Env env = info.Env();
241
+ return Napi::Boolean::New(env, false);
242
+ }
243
+ #endif
package/src/utilities.h CHANGED
@@ -24,5 +24,6 @@ Napi::Value simd(const Napi::CallbackInfo& info);
24
24
  Napi::Value libvipsVersion(const Napi::CallbackInfo& info);
25
25
  Napi::Value format(const Napi::CallbackInfo& info);
26
26
  Napi::Value _maxColourDistance(const Napi::CallbackInfo& info);
27
+ Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info);
27
28
 
28
29
  #endif // SRC_UTILITIES_H_