sharp 0.29.0 → 0.30.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/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;
@@ -95,6 +87,7 @@ struct PipelineBaton {
95
87
  double brightness;
96
88
  double saturation;
97
89
  int hue;
90
+ double lightness;
98
91
  int medianSize;
99
92
  double sharpenSigma;
100
93
  double sharpenFlat;
@@ -126,6 +119,7 @@ struct PipelineBaton {
126
119
  int extendRight;
127
120
  std::vector<double> extendBackground;
128
121
  bool withoutEnlargement;
122
+ bool withoutReduction;
129
123
  std::vector<double> affineMatrix;
130
124
  std::vector<double> affineBackground;
131
125
  double affineIdx;
@@ -146,14 +140,23 @@ struct PipelineBaton {
146
140
  bool pngAdaptiveFiltering;
147
141
  bool pngPalette;
148
142
  int pngQuality;
149
- int pngColours;
143
+ int pngEffort;
144
+ int pngBitdepth;
150
145
  double pngDither;
146
+ int jp2Quality;
147
+ bool jp2Lossless;
148
+ int jp2TileHeight;
149
+ int jp2TileWidth;
150
+ std::string jp2ChromaSubsampling;
151
151
  int webpQuality;
152
152
  int webpAlphaQuality;
153
153
  bool webpNearLossless;
154
154
  bool webpLossless;
155
155
  bool webpSmartSubsample;
156
- int webpReductionEffort;
156
+ int webpEffort;
157
+ int gifBitdepth;
158
+ int gifEffort;
159
+ double gifDither;
157
160
  int tiffQuality;
158
161
  VipsForeignTiffCompression tiffCompression;
159
162
  VipsForeignTiffPredictor tiffPredictor;
@@ -164,9 +167,10 @@ struct PipelineBaton {
164
167
  int tiffTileWidth;
165
168
  double tiffXres;
166
169
  double tiffYres;
170
+ VipsForeignTiffResunit tiffResolutionUnit;
167
171
  int heifQuality;
168
172
  VipsForeignHeifCompression heifCompression;
169
- int heifSpeed;
173
+ int heifEffort;
170
174
  std::string heifChromaSubsampling;
171
175
  bool heifLossless;
172
176
  VipsBandFormat rawDepth;
@@ -176,6 +180,7 @@ struct PipelineBaton {
176
180
  double withMetadataDensity;
177
181
  std::string withMetadataIcc;
178
182
  std::unordered_map<std::string, std::string> withMetadataStrs;
183
+ int timeoutSeconds;
179
184
  std::unique_ptr<double[]> convKernel;
180
185
  int convKernelWidth;
181
186
  int convKernelHeight;
@@ -189,7 +194,6 @@ struct PipelineBaton {
189
194
  double ensureAlpha;
190
195
  VipsInterpretation colourspaceInput;
191
196
  VipsInterpretation colourspace;
192
- int pageHeight;
193
197
  std::vector<int> delay;
194
198
  int loop;
195
199
  int tileSize;
@@ -210,7 +214,7 @@ struct PipelineBaton {
210
214
  topOffsetPre(-1),
211
215
  topOffsetPost(-1),
212
216
  channels(0),
213
- canvas(Canvas::CROP),
217
+ canvas(sharp::Canvas::CROP),
214
218
  position(0),
215
219
  resizeBackground{ 0.0, 0.0, 0.0, 255.0 },
216
220
  hasCropOffset(false),
@@ -227,6 +231,7 @@ struct PipelineBaton {
227
231
  brightness(1.0),
228
232
  saturation(1.0),
229
233
  hue(0),
234
+ lightness(0),
230
235
  medianSize(0),
231
236
  sharpenSigma(0.0),
232
237
  sharpenFlat(1.0),
@@ -256,6 +261,7 @@ struct PipelineBaton {
256
261
  extendRight(0),
257
262
  extendBackground{ 0.0, 0.0, 0.0, 255.0 },
258
263
  withoutEnlargement(false),
264
+ withoutReduction(false),
259
265
  affineMatrix{ 1.0, 0.0, 0.0, 1.0 },
260
266
  affineBackground{ 0.0, 0.0, 0.0, 255.0 },
261
267
  affineIdx(0),
@@ -276,14 +282,20 @@ struct PipelineBaton {
276
282
  pngAdaptiveFiltering(false),
277
283
  pngPalette(false),
278
284
  pngQuality(100),
279
- pngColours(256),
285
+ pngEffort(7),
286
+ pngBitdepth(8),
280
287
  pngDither(1.0),
288
+ jp2Quality(80),
289
+ jp2Lossless(false),
290
+ jp2TileHeight(512),
291
+ jp2TileWidth(512),
292
+ jp2ChromaSubsampling("4:4:4"),
281
293
  webpQuality(80),
282
294
  webpAlphaQuality(100),
283
295
  webpNearLossless(false),
284
296
  webpLossless(false),
285
297
  webpSmartSubsample(false),
286
- webpReductionEffort(4),
298
+ webpEffort(4),
287
299
  tiffQuality(80),
288
300
  tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
289
301
  tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
@@ -294,15 +306,17 @@ struct PipelineBaton {
294
306
  tiffTileWidth(256),
295
307
  tiffXres(1.0),
296
308
  tiffYres(1.0),
309
+ tiffResolutionUnit(VIPS_FOREIGN_TIFF_RESUNIT_INCH),
297
310
  heifQuality(50),
298
311
  heifCompression(VIPS_FOREIGN_HEIF_COMPRESSION_AV1),
299
- heifSpeed(5),
312
+ heifEffort(4),
300
313
  heifChromaSubsampling("4:4:4"),
301
314
  heifLossless(false),
302
315
  rawDepth(VIPS_FORMAT_UCHAR),
303
316
  withMetadata(false),
304
317
  withMetadataOrientation(-1),
305
318
  withMetadataDensity(0.0),
319
+ timeoutSeconds(0),
306
320
  convKernelWidth(0),
307
321
  convKernelHeight(0),
308
322
  convKernelScale(0.0),
@@ -315,8 +329,6 @@ struct PipelineBaton {
315
329
  ensureAlpha(-1.0),
316
330
  colourspaceInput(VIPS_INTERPRETATION_LAST),
317
331
  colourspace(VIPS_INTERPRETATION_LAST),
318
- pageHeight(0),
319
- delay{-1},
320
332
  loop(-1),
321
333
  tileSize(256),
322
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));
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 =