@basemaps/lambda-tiler 8.9.0 → 8.10.1
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/CHANGELOG.md +56 -22
- package/build/__tests__/config.data.js +14 -0
- package/build/__tests__/config.data.js.map +1 -1
- package/build/cli/render.tile.js +25 -9
- package/build/cli/render.tile.js.map +1 -1
- package/build/routes/tile.style.json.js +27 -5
- package/build/routes/tile.style.json.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/config.data.ts +14 -0
- package/src/cli/render.tile.ts +27 -8
- package/src/routes/tile.style.json.ts +26 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +0 -94950
- package/dist/node_modules/.package-lock.json +0 -179
- package/dist/node_modules/@img/sharp-libvips-linux-arm64/README.md +0 -47
- package/dist/node_modules/@img/sharp-libvips-linux-arm64/lib/glib-2.0/include/glibconfig.h +0 -219
- package/dist/node_modules/@img/sharp-libvips-linux-arm64/lib/index.js +0 -1
- package/dist/node_modules/@img/sharp-libvips-linux-arm64/lib/libvips-cpp.so.42 +0 -0
- package/dist/node_modules/@img/sharp-libvips-linux-arm64/package.json +0 -45
- package/dist/node_modules/@img/sharp-libvips-linux-arm64/versions.json +0 -31
- package/dist/node_modules/@img/sharp-linux-arm64/LICENSE +0 -191
- package/dist/node_modules/@img/sharp-linux-arm64/README.md +0 -18
- package/dist/node_modules/@img/sharp-linux-arm64/lib/sharp-linux-arm64.node +0 -0
- package/dist/node_modules/@img/sharp-linux-arm64/package.json +0 -47
- package/dist/node_modules/color/LICENSE +0 -21
- package/dist/node_modules/color/README.md +0 -123
- package/dist/node_modules/color/index.js +0 -496
- package/dist/node_modules/color/package.json +0 -47
- package/dist/node_modules/color-convert/CHANGELOG.md +0 -54
- package/dist/node_modules/color-convert/LICENSE +0 -21
- package/dist/node_modules/color-convert/README.md +0 -68
- package/dist/node_modules/color-convert/conversions.js +0 -839
- package/dist/node_modules/color-convert/index.js +0 -81
- package/dist/node_modules/color-convert/package.json +0 -48
- package/dist/node_modules/color-convert/route.js +0 -97
- package/dist/node_modules/color-name/LICENSE +0 -8
- package/dist/node_modules/color-name/README.md +0 -11
- package/dist/node_modules/color-name/index.js +0 -152
- package/dist/node_modules/color-name/package.json +0 -28
- package/dist/node_modules/color-string/LICENSE +0 -21
- package/dist/node_modules/color-string/README.md +0 -62
- package/dist/node_modules/color-string/index.js +0 -242
- package/dist/node_modules/color-string/package.json +0 -39
- package/dist/node_modules/detect-libc/LICENSE +0 -201
- package/dist/node_modules/detect-libc/README.md +0 -163
- package/dist/node_modules/detect-libc/index.d.ts +0 -14
- package/dist/node_modules/detect-libc/lib/detect-libc.js +0 -267
- package/dist/node_modules/detect-libc/lib/filesystem.js +0 -41
- package/dist/node_modules/detect-libc/lib/process.js +0 -24
- package/dist/node_modules/detect-libc/package.json +0 -41
- package/dist/node_modules/is-arrayish/LICENSE +0 -21
- package/dist/node_modules/is-arrayish/README.md +0 -16
- package/dist/node_modules/is-arrayish/index.js +0 -9
- package/dist/node_modules/is-arrayish/package.json +0 -45
- package/dist/node_modules/is-arrayish/yarn-error.log +0 -1443
- package/dist/node_modules/lerc/CHANGELOG.md +0 -69
- package/dist/node_modules/lerc/LercDecode.d.ts +0 -61
- package/dist/node_modules/lerc/LercDecode.es.d.ts +0 -61
- package/dist/node_modules/lerc/LercDecode.es.js +0 -434
- package/dist/node_modules/lerc/LercDecode.es.min.js +0 -17
- package/dist/node_modules/lerc/LercDecode.js +0 -448
- package/dist/node_modules/lerc/LercDecode.min.js +0 -17
- package/dist/node_modules/lerc/README.md +0 -123
- package/dist/node_modules/lerc/lerc-wasm.wasm +0 -0
- package/dist/node_modules/lerc/package.json +0 -30
- package/dist/node_modules/semver/LICENSE +0 -15
- package/dist/node_modules/semver/README.md +0 -664
- package/dist/node_modules/semver/bin/semver.js +0 -191
- package/dist/node_modules/semver/classes/comparator.js +0 -143
- package/dist/node_modules/semver/classes/index.js +0 -7
- package/dist/node_modules/semver/classes/range.js +0 -556
- package/dist/node_modules/semver/classes/semver.js +0 -319
- package/dist/node_modules/semver/functions/clean.js +0 -8
- package/dist/node_modules/semver/functions/cmp.js +0 -54
- package/dist/node_modules/semver/functions/coerce.js +0 -62
- package/dist/node_modules/semver/functions/compare-build.js +0 -9
- package/dist/node_modules/semver/functions/compare-loose.js +0 -5
- package/dist/node_modules/semver/functions/compare.js +0 -7
- package/dist/node_modules/semver/functions/diff.js +0 -60
- package/dist/node_modules/semver/functions/eq.js +0 -5
- package/dist/node_modules/semver/functions/gt.js +0 -5
- package/dist/node_modules/semver/functions/gte.js +0 -5
- package/dist/node_modules/semver/functions/inc.js +0 -21
- package/dist/node_modules/semver/functions/lt.js +0 -5
- package/dist/node_modules/semver/functions/lte.js +0 -5
- package/dist/node_modules/semver/functions/major.js +0 -5
- package/dist/node_modules/semver/functions/minor.js +0 -5
- package/dist/node_modules/semver/functions/neq.js +0 -5
- package/dist/node_modules/semver/functions/parse.js +0 -18
- package/dist/node_modules/semver/functions/patch.js +0 -5
- package/dist/node_modules/semver/functions/prerelease.js +0 -8
- package/dist/node_modules/semver/functions/rcompare.js +0 -5
- package/dist/node_modules/semver/functions/rsort.js +0 -5
- package/dist/node_modules/semver/functions/satisfies.js +0 -12
- package/dist/node_modules/semver/functions/sort.js +0 -5
- package/dist/node_modules/semver/functions/valid.js +0 -8
- package/dist/node_modules/semver/index.js +0 -91
- package/dist/node_modules/semver/internal/constants.js +0 -37
- package/dist/node_modules/semver/internal/debug.js +0 -11
- package/dist/node_modules/semver/internal/identifiers.js +0 -25
- package/dist/node_modules/semver/internal/lrucache.js +0 -42
- package/dist/node_modules/semver/internal/parse-options.js +0 -17
- package/dist/node_modules/semver/internal/re.js +0 -223
- package/dist/node_modules/semver/package.json +0 -78
- package/dist/node_modules/semver/preload.js +0 -4
- package/dist/node_modules/semver/range.bnf +0 -16
- package/dist/node_modules/semver/ranges/gtr.js +0 -6
- package/dist/node_modules/semver/ranges/intersects.js +0 -9
- package/dist/node_modules/semver/ranges/ltr.js +0 -6
- package/dist/node_modules/semver/ranges/max-satisfying.js +0 -27
- package/dist/node_modules/semver/ranges/min-satisfying.js +0 -26
- package/dist/node_modules/semver/ranges/min-version.js +0 -63
- package/dist/node_modules/semver/ranges/outside.js +0 -82
- package/dist/node_modules/semver/ranges/simplify.js +0 -49
- package/dist/node_modules/semver/ranges/subset.js +0 -249
- package/dist/node_modules/semver/ranges/to-comparators.js +0 -10
- package/dist/node_modules/semver/ranges/valid.js +0 -13
- package/dist/node_modules/sharp/LICENSE +0 -191
- package/dist/node_modules/sharp/README.md +0 -118
- package/dist/node_modules/sharp/install/check.js +0 -36
- package/dist/node_modules/sharp/lib/channel.js +0 -174
- package/dist/node_modules/sharp/lib/colour.js +0 -182
- package/dist/node_modules/sharp/lib/composite.js +0 -210
- package/dist/node_modules/sharp/lib/constructor.js +0 -444
- package/dist/node_modules/sharp/lib/index.d.ts +0 -1717
- package/dist/node_modules/sharp/lib/index.js +0 -16
- package/dist/node_modules/sharp/lib/input.js +0 -657
- package/dist/node_modules/sharp/lib/is.js +0 -169
- package/dist/node_modules/sharp/lib/libvips.js +0 -171
- package/dist/node_modules/sharp/lib/operation.js +0 -919
- package/dist/node_modules/sharp/lib/output.js +0 -1561
- package/dist/node_modules/sharp/lib/resize.js +0 -582
- package/dist/node_modules/sharp/lib/sharp.js +0 -86
- package/dist/node_modules/sharp/lib/utility.js +0 -287
- package/dist/node_modules/sharp/package.json +0 -219
- package/dist/node_modules/sharp/src/binding.gyp +0 -277
- package/dist/node_modules/sharp/src/common.cc +0 -1090
- package/dist/node_modules/sharp/src/common.h +0 -393
- package/dist/node_modules/sharp/src/metadata.cc +0 -287
- package/dist/node_modules/sharp/src/metadata.h +0 -82
- package/dist/node_modules/sharp/src/operations.cc +0 -471
- package/dist/node_modules/sharp/src/operations.h +0 -125
- package/dist/node_modules/sharp/src/pipeline.cc +0 -1724
- package/dist/node_modules/sharp/src/pipeline.h +0 -385
- package/dist/node_modules/sharp/src/sharp.cc +0 -40
- package/dist/node_modules/sharp/src/stats.cc +0 -183
- package/dist/node_modules/sharp/src/stats.h +0 -59
- package/dist/node_modules/sharp/src/utilities.cc +0 -269
- package/dist/node_modules/sharp/src/utilities.h +0 -19
- package/dist/node_modules/simple-swizzle/LICENSE +0 -21
- package/dist/node_modules/simple-swizzle/README.md +0 -39
- package/dist/node_modules/simple-swizzle/index.js +0 -29
- package/dist/node_modules/simple-swizzle/package.json +0 -36
- package/dist/package-lock.json +0 -610
- package/dist/package.json +0 -40
- package/dist/static/expected_tile_2193_153_255_z7.png +0 -0
- package/dist/static/expected_tile_NZTM2000Quad_30_33_z6.png +0 -0
- package/dist/static/expected_tile_WebMercatorQuad_252_156_z8.png +0 -0
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
// Copyright 2013 Lovell Fuller and others.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
#include <cmath>
|
|
5
|
-
#include <string>
|
|
6
|
-
#include <cstdio>
|
|
7
|
-
|
|
8
|
-
#include <napi.h>
|
|
9
|
-
#include <vips/vips8>
|
|
10
|
-
#include <vips/vector.h>
|
|
11
|
-
|
|
12
|
-
#include "common.h"
|
|
13
|
-
#include "operations.h"
|
|
14
|
-
#include "utilities.h"
|
|
15
|
-
|
|
16
|
-
/*
|
|
17
|
-
Get and set cache limits
|
|
18
|
-
*/
|
|
19
|
-
Napi::Value cache(const Napi::CallbackInfo& info) {
|
|
20
|
-
Napi::Env env = info.Env();
|
|
21
|
-
|
|
22
|
-
// Set memory limit
|
|
23
|
-
if (info[size_t(0)].IsNumber()) {
|
|
24
|
-
vips_cache_set_max_mem(info[size_t(0)].As<Napi::Number>().Int32Value() * 1048576);
|
|
25
|
-
}
|
|
26
|
-
// Set file limit
|
|
27
|
-
if (info[size_t(1)].IsNumber()) {
|
|
28
|
-
vips_cache_set_max_files(info[size_t(1)].As<Napi::Number>().Int32Value());
|
|
29
|
-
}
|
|
30
|
-
// Set items limit
|
|
31
|
-
if (info[size_t(2)].IsNumber()) {
|
|
32
|
-
vips_cache_set_max(info[size_t(2)].As<Napi::Number>().Int32Value());
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Get memory stats
|
|
36
|
-
Napi::Object memory = Napi::Object::New(env);
|
|
37
|
-
memory.Set("current", round(vips_tracked_get_mem() / 1048576));
|
|
38
|
-
memory.Set("high", round(vips_tracked_get_mem_highwater() / 1048576));
|
|
39
|
-
memory.Set("max", round(vips_cache_get_max_mem() / 1048576));
|
|
40
|
-
// Get file stats
|
|
41
|
-
Napi::Object files = Napi::Object::New(env);
|
|
42
|
-
files.Set("current", vips_tracked_get_files());
|
|
43
|
-
files.Set("max", vips_cache_get_max_files());
|
|
44
|
-
|
|
45
|
-
// Get item stats
|
|
46
|
-
Napi::Object items = Napi::Object::New(env);
|
|
47
|
-
items.Set("current", vips_cache_get_size());
|
|
48
|
-
items.Set("max", vips_cache_get_max());
|
|
49
|
-
|
|
50
|
-
Napi::Object cache = Napi::Object::New(env);
|
|
51
|
-
cache.Set("memory", memory);
|
|
52
|
-
cache.Set("files", files);
|
|
53
|
-
cache.Set("items", items);
|
|
54
|
-
return cache;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/*
|
|
58
|
-
Get and set size of thread pool
|
|
59
|
-
*/
|
|
60
|
-
Napi::Value concurrency(const Napi::CallbackInfo& info) {
|
|
61
|
-
// Set concurrency
|
|
62
|
-
if (info[size_t(0)].IsNumber()) {
|
|
63
|
-
vips_concurrency_set(info[size_t(0)].As<Napi::Number>().Int32Value());
|
|
64
|
-
}
|
|
65
|
-
// Get concurrency
|
|
66
|
-
return Napi::Number::New(info.Env(), vips_concurrency_get());
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/*
|
|
70
|
-
Get internal counters (queued tasks, processing tasks)
|
|
71
|
-
*/
|
|
72
|
-
Napi::Value counters(const Napi::CallbackInfo& info) {
|
|
73
|
-
Napi::Object counters = Napi::Object::New(info.Env());
|
|
74
|
-
counters.Set("queue", static_cast<int>(sharp::counterQueue));
|
|
75
|
-
counters.Set("process", static_cast<int>(sharp::counterProcess));
|
|
76
|
-
return counters;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/*
|
|
80
|
-
Get and set use of SIMD vector unit instructions
|
|
81
|
-
*/
|
|
82
|
-
Napi::Value simd(const Napi::CallbackInfo& info) {
|
|
83
|
-
// Set state
|
|
84
|
-
if (info[size_t(0)].IsBoolean()) {
|
|
85
|
-
vips_vector_set_enabled(info[size_t(0)].As<Napi::Boolean>().Value());
|
|
86
|
-
}
|
|
87
|
-
// Get state
|
|
88
|
-
return Napi::Boolean::New(info.Env(), vips_vector_isenabled());
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/*
|
|
92
|
-
Get libvips version
|
|
93
|
-
*/
|
|
94
|
-
Napi::Value libvipsVersion(const Napi::CallbackInfo& info) {
|
|
95
|
-
Napi::Env env = info.Env();
|
|
96
|
-
Napi::Object version = Napi::Object::New(env);
|
|
97
|
-
|
|
98
|
-
char semver[9];
|
|
99
|
-
std::snprintf(semver, sizeof(semver), "%d.%d.%d", vips_version(0), vips_version(1), vips_version(2));
|
|
100
|
-
version.Set("semver", Napi::String::New(env, semver));
|
|
101
|
-
#ifdef SHARP_USE_GLOBAL_LIBVIPS
|
|
102
|
-
version.Set("isGlobal", Napi::Boolean::New(env, true));
|
|
103
|
-
#else
|
|
104
|
-
version.Set("isGlobal", Napi::Boolean::New(env, false));
|
|
105
|
-
#endif
|
|
106
|
-
#ifdef __EMSCRIPTEN__
|
|
107
|
-
version.Set("isWasm", Napi::Boolean::New(env, true));
|
|
108
|
-
#else
|
|
109
|
-
version.Set("isWasm", Napi::Boolean::New(env, false));
|
|
110
|
-
#endif
|
|
111
|
-
return version;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/*
|
|
115
|
-
Get available input/output file/buffer/stream formats
|
|
116
|
-
*/
|
|
117
|
-
Napi::Value format(const Napi::CallbackInfo& info) {
|
|
118
|
-
Napi::Env env = info.Env();
|
|
119
|
-
Napi::Object format = Napi::Object::New(env);
|
|
120
|
-
for (std::string const f : {
|
|
121
|
-
"jpeg", "png", "webp", "tiff", "magick", "openslide", "dz",
|
|
122
|
-
"ppm", "fits", "gif", "svg", "heif", "pdf", "vips", "jp2k", "jxl"
|
|
123
|
-
}) {
|
|
124
|
-
// Input
|
|
125
|
-
const VipsObjectClass *oc = vips_class_find("VipsOperation", (f + "load").c_str());
|
|
126
|
-
Napi::Boolean hasInputFile = Napi::Boolean::New(env, oc);
|
|
127
|
-
Napi::Boolean hasInputBuffer =
|
|
128
|
-
Napi::Boolean::New(env, vips_type_find("VipsOperation", (f + "load_buffer").c_str()));
|
|
129
|
-
Napi::Object input = Napi::Object::New(env);
|
|
130
|
-
input.Set("file", hasInputFile);
|
|
131
|
-
input.Set("buffer", hasInputBuffer);
|
|
132
|
-
input.Set("stream", hasInputBuffer);
|
|
133
|
-
if (hasInputFile) {
|
|
134
|
-
const VipsForeignClass *fc = VIPS_FOREIGN_CLASS(oc);
|
|
135
|
-
if (fc->suffs) {
|
|
136
|
-
Napi::Array fileSuffix = Napi::Array::New(env);
|
|
137
|
-
const char **suffix = fc->suffs;
|
|
138
|
-
for (int i = 0; *suffix; i++, suffix++) {
|
|
139
|
-
fileSuffix.Set(i, Napi::String::New(env, *suffix));
|
|
140
|
-
}
|
|
141
|
-
input.Set("fileSuffix", fileSuffix);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
// Output
|
|
145
|
-
Napi::Boolean hasOutputFile =
|
|
146
|
-
Napi::Boolean::New(env, vips_type_find("VipsOperation", (f + "save").c_str()));
|
|
147
|
-
Napi::Boolean hasOutputBuffer =
|
|
148
|
-
Napi::Boolean::New(env, vips_type_find("VipsOperation", (f + "save_buffer").c_str()));
|
|
149
|
-
Napi::Object output = Napi::Object::New(env);
|
|
150
|
-
output.Set("file", hasOutputFile);
|
|
151
|
-
output.Set("buffer", hasOutputBuffer);
|
|
152
|
-
output.Set("stream", hasOutputBuffer);
|
|
153
|
-
// Other attributes
|
|
154
|
-
Napi::Object container = Napi::Object::New(env);
|
|
155
|
-
container.Set("id", f);
|
|
156
|
-
container.Set("input", input);
|
|
157
|
-
container.Set("output", output);
|
|
158
|
-
// Add to set of formats
|
|
159
|
-
format.Set(f, container);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Raw, uncompressed data
|
|
163
|
-
Napi::Boolean supported = Napi::Boolean::New(env, true);
|
|
164
|
-
Napi::Boolean unsupported = Napi::Boolean::New(env, false);
|
|
165
|
-
Napi::Object rawInput = Napi::Object::New(env);
|
|
166
|
-
rawInput.Set("file", unsupported);
|
|
167
|
-
rawInput.Set("buffer", supported);
|
|
168
|
-
rawInput.Set("stream", supported);
|
|
169
|
-
Napi::Object rawOutput = Napi::Object::New(env);
|
|
170
|
-
rawOutput.Set("file", unsupported);
|
|
171
|
-
rawOutput.Set("buffer", supported);
|
|
172
|
-
rawOutput.Set("stream", supported);
|
|
173
|
-
Napi::Object raw = Napi::Object::New(env);
|
|
174
|
-
raw.Set("id", "raw");
|
|
175
|
-
raw.Set("input", rawInput);
|
|
176
|
-
raw.Set("output", rawOutput);
|
|
177
|
-
format.Set("raw", raw);
|
|
178
|
-
|
|
179
|
-
return format;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/*
|
|
183
|
-
(Un)block libvips operations at runtime.
|
|
184
|
-
*/
|
|
185
|
-
void block(const Napi::CallbackInfo& info) {
|
|
186
|
-
Napi::Array ops = info[size_t(0)].As<Napi::Array>();
|
|
187
|
-
bool const state = info[size_t(1)].As<Napi::Boolean>().Value();
|
|
188
|
-
for (unsigned int i = 0; i < ops.Length(); i++) {
|
|
189
|
-
vips_operation_block_set(ops.Get(i).As<Napi::String>().Utf8Value().c_str(), state);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/*
|
|
194
|
-
Synchronous, internal-only method used by some of the functional tests.
|
|
195
|
-
Calculates the maximum colour distance using the DE2000 algorithm
|
|
196
|
-
between two images of the same dimensions and number of channels.
|
|
197
|
-
*/
|
|
198
|
-
Napi::Value _maxColourDistance(const Napi::CallbackInfo& info) {
|
|
199
|
-
Napi::Env env = info.Env();
|
|
200
|
-
|
|
201
|
-
// Open input files
|
|
202
|
-
VImage image1;
|
|
203
|
-
sharp::ImageType imageType1 = sharp::DetermineImageType(info[size_t(0)].As<Napi::String>().Utf8Value().data());
|
|
204
|
-
if (imageType1 != sharp::ImageType::UNKNOWN) {
|
|
205
|
-
try {
|
|
206
|
-
image1 = VImage::new_from_file(info[size_t(0)].As<Napi::String>().Utf8Value().c_str());
|
|
207
|
-
} catch (...) {
|
|
208
|
-
throw Napi::Error::New(env, "Input file 1 has corrupt header");
|
|
209
|
-
}
|
|
210
|
-
} else {
|
|
211
|
-
throw Napi::Error::New(env, "Input file 1 is of an unsupported image format");
|
|
212
|
-
}
|
|
213
|
-
VImage image2;
|
|
214
|
-
sharp::ImageType imageType2 = sharp::DetermineImageType(info[size_t(1)].As<Napi::String>().Utf8Value().data());
|
|
215
|
-
if (imageType2 != sharp::ImageType::UNKNOWN) {
|
|
216
|
-
try {
|
|
217
|
-
image2 = VImage::new_from_file(info[size_t(1)].As<Napi::String>().Utf8Value().c_str());
|
|
218
|
-
} catch (...) {
|
|
219
|
-
throw Napi::Error::New(env, "Input file 2 has corrupt header");
|
|
220
|
-
}
|
|
221
|
-
} else {
|
|
222
|
-
throw Napi::Error::New(env, "Input file 2 is of an unsupported image format");
|
|
223
|
-
}
|
|
224
|
-
// Ensure same number of channels
|
|
225
|
-
if (image1.bands() != image2.bands()) {
|
|
226
|
-
throw Napi::Error::New(env, "mismatchedBands");
|
|
227
|
-
}
|
|
228
|
-
// Ensure same dimensions
|
|
229
|
-
if (image1.width() != image2.width() || image1.height() != image2.height()) {
|
|
230
|
-
throw Napi::Error::New(env, "mismatchedDimensions");
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
double maxColourDistance;
|
|
234
|
-
try {
|
|
235
|
-
// Premultiply and remove alpha
|
|
236
|
-
if (sharp::HasAlpha(image1)) {
|
|
237
|
-
image1 = image1.premultiply().extract_band(1, VImage::option()->set("n", image1.bands() - 1));
|
|
238
|
-
}
|
|
239
|
-
if (sharp::HasAlpha(image2)) {
|
|
240
|
-
image2 = image2.premultiply().extract_band(1, VImage::option()->set("n", image2.bands() - 1));
|
|
241
|
-
}
|
|
242
|
-
// Calculate colour distance
|
|
243
|
-
maxColourDistance = image1.dE00(image2).max();
|
|
244
|
-
} catch (vips::VError const &err) {
|
|
245
|
-
throw Napi::Error::New(env, err.what());
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// Clean up libvips' per-request data and threads
|
|
249
|
-
vips_error_clear();
|
|
250
|
-
vips_thread_shutdown();
|
|
251
|
-
|
|
252
|
-
return Napi::Number::New(env, maxColourDistance);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
#if defined(__GNUC__)
|
|
256
|
-
// mallctl will be resolved by the runtime linker when jemalloc is being used
|
|
257
|
-
extern "C" {
|
|
258
|
-
int mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) __attribute__((weak));
|
|
259
|
-
}
|
|
260
|
-
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
|
|
261
|
-
Napi::Env env = info.Env();
|
|
262
|
-
return Napi::Boolean::New(env, mallctl != nullptr);
|
|
263
|
-
}
|
|
264
|
-
#else
|
|
265
|
-
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
|
|
266
|
-
Napi::Env env = info.Env();
|
|
267
|
-
return Napi::Boolean::New(env, false);
|
|
268
|
-
}
|
|
269
|
-
#endif
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Copyright 2013 Lovell Fuller and others.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
#ifndef SRC_UTILITIES_H_
|
|
5
|
-
#define SRC_UTILITIES_H_
|
|
6
|
-
|
|
7
|
-
#include <napi.h>
|
|
8
|
-
|
|
9
|
-
Napi::Value cache(const Napi::CallbackInfo& info);
|
|
10
|
-
Napi::Value concurrency(const Napi::CallbackInfo& info);
|
|
11
|
-
Napi::Value counters(const Napi::CallbackInfo& info);
|
|
12
|
-
Napi::Value simd(const Napi::CallbackInfo& info);
|
|
13
|
-
Napi::Value libvipsVersion(const Napi::CallbackInfo& info);
|
|
14
|
-
Napi::Value format(const Napi::CallbackInfo& info);
|
|
15
|
-
void block(const Napi::CallbackInfo& info);
|
|
16
|
-
Napi::Value _maxColourDistance(const Napi::CallbackInfo& info);
|
|
17
|
-
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info);
|
|
18
|
-
|
|
19
|
-
#endif // SRC_UTILITIES_H_
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 Josh Junon
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# simple-swizzle [](https://travis-ci.org/Qix-/node-simple-swizzle) [](https://coveralls.io/r/Qix-/node-simple-swizzle)
|
|
2
|
-
|
|
3
|
-
> [Swizzle](https://en.wikipedia.org/wiki/Swizzling_(computer_graphics)) your function arguments; pass in mixed arrays/values and get a clean array
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
var swizzle = require('simple-swizzle');
|
|
9
|
-
|
|
10
|
-
function myFunc() {
|
|
11
|
-
var args = swizzle(arguments);
|
|
12
|
-
// ...
|
|
13
|
-
return args;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
myFunc(1, [2, 3], 4); // [1, 2, 3, 4]
|
|
17
|
-
myFunc(1, 2, 3, 4); // [1, 2, 3, 4]
|
|
18
|
-
myFunc([1, 2, 3, 4]); // [1, 2, 3, 4]
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Functions can also be wrapped to automatically swizzle arguments and be passed
|
|
22
|
-
the resulting array.
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
var swizzle = require('simple-swizzle');
|
|
26
|
-
|
|
27
|
-
var swizzledFn = swizzle.wrap(function (args) {
|
|
28
|
-
// ...
|
|
29
|
-
return args;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
swizzledFn(1, [2, 3], 4); // [1, 2, 3, 4]
|
|
33
|
-
swizzledFn(1, 2, 3, 4); // [1, 2, 3, 4]
|
|
34
|
-
swizzledFn([1, 2, 3, 4]); // [1, 2, 3, 4]
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## License
|
|
38
|
-
Licensed under the [MIT License](http://opensource.org/licenses/MIT).
|
|
39
|
-
You can find a copy of it in [LICENSE](LICENSE).
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var isArrayish = require('is-arrayish');
|
|
4
|
-
|
|
5
|
-
var concat = Array.prototype.concat;
|
|
6
|
-
var slice = Array.prototype.slice;
|
|
7
|
-
|
|
8
|
-
var swizzle = module.exports = function swizzle(args) {
|
|
9
|
-
var results = [];
|
|
10
|
-
|
|
11
|
-
for (var i = 0, len = args.length; i < len; i++) {
|
|
12
|
-
var arg = args[i];
|
|
13
|
-
|
|
14
|
-
if (isArrayish(arg)) {
|
|
15
|
-
// http://jsperf.com/javascript-array-concat-vs-push/98
|
|
16
|
-
results = concat.call(results, slice.call(arg));
|
|
17
|
-
} else {
|
|
18
|
-
results.push(arg);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return results;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
swizzle.wrap = function (fn) {
|
|
26
|
-
return function () {
|
|
27
|
-
return fn(swizzle(arguments));
|
|
28
|
-
};
|
|
29
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "simple-swizzle",
|
|
3
|
-
"description": "Simply swizzle your arguments",
|
|
4
|
-
"version": "0.2.2",
|
|
5
|
-
"author": "Qix (http://github.com/qix-)",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"argument",
|
|
8
|
-
"arguments",
|
|
9
|
-
"swizzle",
|
|
10
|
-
"swizzling",
|
|
11
|
-
"parameter",
|
|
12
|
-
"parameters",
|
|
13
|
-
"mixed",
|
|
14
|
-
"array"
|
|
15
|
-
],
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"scripts": {
|
|
18
|
-
"pretest": "xo",
|
|
19
|
-
"test": "mocha --compilers coffee:coffee-script/register"
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"index.js"
|
|
23
|
-
],
|
|
24
|
-
"repository": "qix-/node-simple-swizzle",
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"coffee-script": "^1.9.3",
|
|
27
|
-
"coveralls": "^2.11.2",
|
|
28
|
-
"istanbul": "^0.3.17",
|
|
29
|
-
"mocha": "^2.2.5",
|
|
30
|
-
"should": "^7.0.1",
|
|
31
|
-
"xo": "^0.7.1"
|
|
32
|
-
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"is-arrayish": "^0.3.1"
|
|
35
|
-
}
|
|
36
|
-
}
|