sharp 0.31.2 → 0.32.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
@@ -1,16 +1,5 @@
1
- // Copyright 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Lovell Fuller and contributors.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
14
3
 
15
4
  #ifndef SRC_PIPELINE_H_
16
5
  #define SRC_PIPELINE_H_
@@ -74,6 +63,9 @@ struct PipelineBaton {
74
63
  bool hasCropOffset;
75
64
  int cropOffsetLeft;
76
65
  int cropOffsetTop;
66
+ bool hasAttentionCenter;
67
+ int attentionX;
68
+ int attentionY;
77
69
  bool premultiplied;
78
70
  bool tileCentre;
79
71
  bool fastShrinkOnLoad;
@@ -107,6 +99,8 @@ struct PipelineBaton {
107
99
  double gammaOut;
108
100
  bool greyscale;
109
101
  bool normalise;
102
+ int normaliseLower;
103
+ int normaliseUpper;
110
104
  int claheWidth;
111
105
  int claheHeight;
112
106
  int claheMaxSlope;
@@ -122,6 +116,7 @@ struct PipelineBaton {
122
116
  int extendLeft;
123
117
  int extendRight;
124
118
  std::vector<double> extendBackground;
119
+ VipsExtend extendWith;
125
120
  bool withoutEnlargement;
126
121
  bool withoutReduction;
127
122
  std::vector<double> affineMatrix;
@@ -163,7 +158,10 @@ struct PipelineBaton {
163
158
  int gifBitdepth;
164
159
  int gifEffort;
165
160
  double gifDither;
166
- bool gifReoptimise;
161
+ double gifInterFrameMaxError;
162
+ double gifInterPaletteMaxError;
163
+ bool gifReuse;
164
+ bool gifProgressive;
167
165
  int tiffQuality;
168
166
  VipsForeignTiffCompression tiffCompression;
169
167
  VipsForeignTiffPredictor tiffPredictor;
@@ -180,6 +178,10 @@ struct PipelineBaton {
180
178
  int heifEffort;
181
179
  std::string heifChromaSubsampling;
182
180
  bool heifLossless;
181
+ double jxlDistance;
182
+ int jxlDecodingTier;
183
+ int jxlEffort;
184
+ bool jxlLossless;
183
185
  VipsBandFormat rawDepth;
184
186
  std::string err;
185
187
  bool withMetadata;
@@ -229,6 +231,9 @@ struct PipelineBaton {
229
231
  hasCropOffset(false),
230
232
  cropOffsetLeft(0),
231
233
  cropOffsetTop(0),
234
+ hasAttentionCenter(false),
235
+ attentionX(0),
236
+ attentionY(0),
232
237
  premultiplied(false),
233
238
  tintA(128.0),
234
239
  tintB(128.0),
@@ -259,6 +264,8 @@ struct PipelineBaton {
259
264
  gamma(0.0),
260
265
  greyscale(false),
261
266
  normalise(false),
267
+ normaliseLower(1),
268
+ normaliseUpper(99),
262
269
  claheWidth(0),
263
270
  claheHeight(0),
264
271
  claheMaxSlope(3),
@@ -273,6 +280,7 @@ struct PipelineBaton {
273
280
  extendLeft(0),
274
281
  extendRight(0),
275
282
  extendBackground{ 0.0, 0.0, 0.0, 255.0 },
283
+ extendWith(VIPS_EXTEND_BACKGROUND),
276
284
  withoutEnlargement(false),
277
285
  withoutReduction(false),
278
286
  affineMatrix{ 1.0, 0.0, 0.0, 1.0 },
@@ -314,7 +322,10 @@ struct PipelineBaton {
314
322
  gifBitdepth(8),
315
323
  gifEffort(7),
316
324
  gifDither(1.0),
317
- gifReoptimise(false),
325
+ gifInterFrameMaxError(0.0),
326
+ gifInterPaletteMaxError(3.0),
327
+ gifReuse(true),
328
+ gifProgressive(false),
318
329
  tiffQuality(80),
319
330
  tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
320
331
  tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
@@ -331,6 +342,10 @@ struct PipelineBaton {
331
342
  heifEffort(4),
332
343
  heifChromaSubsampling("4:4:4"),
333
344
  heifLossless(false),
345
+ jxlDistance(1.0),
346
+ jxlDecodingTier(0),
347
+ jxlEffort(7),
348
+ jxlLossless(false),
334
349
  rawDepth(VIPS_FORMAT_UCHAR),
335
350
  withMetadata(false),
336
351
  withMetadataOrientation(-1),
package/src/sharp.cc CHANGED
@@ -1,16 +1,5 @@
1
- // Copyright 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Lovell Fuller and contributors.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
14
3
 
15
4
  #include <napi.h>
16
5
  #include <vips/vips8>
package/src/stats.cc CHANGED
@@ -1,16 +1,5 @@
1
- // Copyright 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Lovell Fuller and contributors.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
14
3
 
15
4
  #include <numeric>
16
5
  #include <vector>
@@ -117,7 +106,7 @@ class StatsWorker : public Napi::AsyncWorker {
117
106
  // Handle warnings
118
107
  std::string warning = sharp::VipsWarningPop();
119
108
  while (!warning.empty()) {
120
- debuglog.Call({ Napi::String::New(env, warning) });
109
+ debuglog.MakeCallback(Receiver().Value(), { Napi::String::New(env, warning) });
121
110
  warning = sharp::VipsWarningPop();
122
111
  }
123
112
 
@@ -154,7 +143,7 @@ class StatsWorker : public Napi::AsyncWorker {
154
143
  info.Set("dominant", dominant);
155
144
  Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
156
145
  } else {
157
- Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, baton->err).Value() });
146
+ Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
158
147
  }
159
148
 
160
149
  delete baton->input;
@@ -172,16 +161,17 @@ class StatsWorker : public Napi::AsyncWorker {
172
161
  Napi::Value stats(const Napi::CallbackInfo& info) {
173
162
  // V8 objects are converted to non-V8 types held in the baton struct
174
163
  StatsBaton *baton = new StatsBaton;
175
- Napi::Object options = info[0].As<Napi::Object>();
164
+ Napi::Object options = info[size_t(0)].As<Napi::Object>();
176
165
 
177
166
  // Input
178
167
  baton->input = sharp::CreateInputDescriptor(options.Get("input").As<Napi::Object>());
168
+ baton->input->access = VIPS_ACCESS_RANDOM;
179
169
 
180
170
  // Function to notify of libvips warnings
181
171
  Napi::Function debuglog = options.Get("debuglog").As<Napi::Function>();
182
172
 
183
173
  // Join queue for worker thread
184
- Napi::Function callback = info[1].As<Napi::Function>();
174
+ Napi::Function callback = info[size_t(1)].As<Napi::Function>();
185
175
  StatsWorker *worker = new StatsWorker(callback, baton, debuglog);
186
176
  worker->Receiver().Set("options", options);
187
177
  worker->Queue();
package/src/stats.h CHANGED
@@ -1,16 +1,5 @@
1
- // Copyright 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Lovell Fuller and contributors.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
14
3
 
15
4
  #ifndef SRC_STATS_H_
16
5
  #define SRC_STATS_H_
package/src/utilities.cc CHANGED
@@ -1,16 +1,5 @@
1
- // Copyright 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Lovell Fuller and contributors.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
14
3
 
15
4
  #include <cmath>
16
5
  #include <string>
@@ -30,16 +19,16 @@ Napi::Value cache(const Napi::CallbackInfo& info) {
30
19
  Napi::Env env = info.Env();
31
20
 
32
21
  // Set memory limit
33
- if (info[0].IsNumber()) {
34
- vips_cache_set_max_mem(info[0].As<Napi::Number>().Int32Value() * 1048576);
22
+ if (info[size_t(0)].IsNumber()) {
23
+ vips_cache_set_max_mem(info[size_t(0)].As<Napi::Number>().Int32Value() * 1048576);
35
24
  }
36
25
  // Set file limit
37
- if (info[1].IsNumber()) {
38
- vips_cache_set_max_files(info[1].As<Napi::Number>().Int32Value());
26
+ if (info[size_t(1)].IsNumber()) {
27
+ vips_cache_set_max_files(info[size_t(1)].As<Napi::Number>().Int32Value());
39
28
  }
40
29
  // Set items limit
41
- if (info[2].IsNumber()) {
42
- vips_cache_set_max(info[2].As<Napi::Number>().Int32Value());
30
+ if (info[size_t(2)].IsNumber()) {
31
+ vips_cache_set_max(info[size_t(2)].As<Napi::Number>().Int32Value());
43
32
  }
44
33
 
45
34
  // Get memory stats
@@ -69,8 +58,8 @@ Napi::Value cache(const Napi::CallbackInfo& info) {
69
58
  */
70
59
  Napi::Value concurrency(const Napi::CallbackInfo& info) {
71
60
  // Set concurrency
72
- if (info[0].IsNumber()) {
73
- vips_concurrency_set(info[0].As<Napi::Number>().Int32Value());
61
+ if (info[size_t(0)].IsNumber()) {
62
+ vips_concurrency_set(info[size_t(0)].As<Napi::Number>().Int32Value());
74
63
  }
75
64
  // Get concurrency
76
65
  return Napi::Number::New(info.Env(), vips_concurrency_get());
@@ -91,8 +80,8 @@ Napi::Value counters(const Napi::CallbackInfo& info) {
91
80
  */
92
81
  Napi::Value simd(const Napi::CallbackInfo& info) {
93
82
  // Set state
94
- if (info[0].IsBoolean()) {
95
- vips_vector_set_enabled(info[0].As<Napi::Boolean>().Value());
83
+ if (info[size_t(0)].IsBoolean()) {
84
+ vips_vector_set_enabled(info[size_t(0)].As<Napi::Boolean>().Value());
96
85
  }
97
86
  // Get state
98
87
  return Napi::Boolean::New(info.Env(), vips_vector_isenabled());
@@ -115,7 +104,7 @@ Napi::Value format(const Napi::CallbackInfo& info) {
115
104
  Napi::Object format = Napi::Object::New(env);
116
105
  for (std::string const f : {
117
106
  "jpeg", "png", "webp", "tiff", "magick", "openslide", "dz",
118
- "ppm", "fits", "gif", "svg", "heif", "pdf", "vips", "jp2k"
107
+ "ppm", "fits", "gif", "svg", "heif", "pdf", "vips", "jp2k", "jxl"
119
108
  }) {
120
109
  // Input
121
110
  const VipsObjectClass *oc = vips_class_find("VipsOperation", (f + "load").c_str());
@@ -185,10 +174,10 @@ Napi::Value _maxColourDistance(const Napi::CallbackInfo& info) {
185
174
 
186
175
  // Open input files
187
176
  VImage image1;
188
- sharp::ImageType imageType1 = sharp::DetermineImageType(info[0].As<Napi::String>().Utf8Value().data());
177
+ sharp::ImageType imageType1 = sharp::DetermineImageType(info[size_t(0)].As<Napi::String>().Utf8Value().data());
189
178
  if (imageType1 != sharp::ImageType::UNKNOWN) {
190
179
  try {
191
- image1 = VImage::new_from_file(info[0].As<Napi::String>().Utf8Value().c_str());
180
+ image1 = VImage::new_from_file(info[size_t(0)].As<Napi::String>().Utf8Value().c_str());
192
181
  } catch (...) {
193
182
  throw Napi::Error::New(env, "Input file 1 has corrupt header");
194
183
  }
@@ -196,10 +185,10 @@ Napi::Value _maxColourDistance(const Napi::CallbackInfo& info) {
196
185
  throw Napi::Error::New(env, "Input file 1 is of an unsupported image format");
197
186
  }
198
187
  VImage image2;
199
- sharp::ImageType imageType2 = sharp::DetermineImageType(info[1].As<Napi::String>().Utf8Value().data());
188
+ sharp::ImageType imageType2 = sharp::DetermineImageType(info[size_t(1)].As<Napi::String>().Utf8Value().data());
200
189
  if (imageType2 != sharp::ImageType::UNKNOWN) {
201
190
  try {
202
- image2 = VImage::new_from_file(info[1].As<Napi::String>().Utf8Value().c_str());
191
+ image2 = VImage::new_from_file(info[size_t(1)].As<Napi::String>().Utf8Value().c_str());
203
192
  } catch (...) {
204
193
  throw Napi::Error::New(env, "Input file 2 has corrupt header");
205
194
  }
package/src/utilities.h CHANGED
@@ -1,16 +1,5 @@
1
- // Copyright 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Lovell Fuller and contributors.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
14
3
 
15
4
  #ifndef SRC_UTILITIES_H_
16
5
  #define SRC_UTILITIES_H_