pica 10.0.0 → 10.0.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.
@@ -5,183 +5,105 @@ https://github.com/nodeca/pica
5
5
 
6
6
  */
7
7
  (function() {
8
- var __create = Object.create;
9
- var __defProp = Object.defineProperty;
10
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
- var __getOwnPropNames = Object.getOwnPropertyNames;
12
- var __getProtoOf = Object.getPrototypeOf;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
17
- key = keys[i];
18
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
- get: ((k) => from[k]).bind(null, key),
20
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
- });
22
- }
23
- return to;
24
- };
25
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: true
28
- }) : target, mod));
29
- /*
30
- object-assign
31
- (c) Sindre Sorhus
32
- @license MIT
33
- */
34
- var require_object_assign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
35
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
36
- var hasOwnProperty = Object.prototype.hasOwnProperty;
37
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
38
- function toObject(val) {
39
- if (val === null || val === void 0) throw new TypeError("Object.assign cannot be called with null or undefined");
40
- return Object(val);
41
- }
42
- function shouldUseNative() {
43
- try {
44
- if (!Object.assign) return false;
45
- var test1 = /* @__PURE__ */ new String("abc");
46
- test1[5] = "de";
47
- if (Object.getOwnPropertyNames(test1)[0] === "5") return false;
48
- var test2 = {};
49
- for (var i = 0; i < 10; i++) test2["_" + String.fromCharCode(i)] = i;
50
- if (Object.getOwnPropertyNames(test2).map(function(n) {
51
- return test2[n];
52
- }).join("") !== "0123456789") return false;
53
- var test3 = {};
54
- "abcdefghijklmnopqrst".split("").forEach(function(letter) {
55
- test3[letter] = letter;
56
- });
57
- if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") return false;
58
- return true;
59
- } catch (err) {
60
- return false;
61
- }
62
- }
63
- module.exports = shouldUseNative() ? Object.assign : function(target, source) {
64
- var from;
65
- var to = toObject(target);
66
- var symbols;
67
- for (var s = 1; s < arguments.length; s++) {
68
- from = Object(arguments[s]);
69
- for (var key in from) if (hasOwnProperty.call(from, key)) to[key] = from[key];
70
- if (getOwnPropertySymbols) {
71
- symbols = getOwnPropertySymbols(from);
72
- for (var i = 0; i < symbols.length; i++) if (propIsEnumerable.call(from, symbols[i])) to[symbols[i]] = from[symbols[i]];
73
- }
74
- }
75
- return to;
76
- };
77
- }));
78
- var require_base64decode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
79
- var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
80
- module.exports = function base64decode(str) {
81
- var input = str.replace(/[\r\n=]/g, ""), max = input.length;
82
- var out = new Uint8Array(max * 3 >> 2);
83
- var bits = 0;
84
- var ptr = 0;
85
- for (var idx = 0; idx < max; idx++) {
86
- if (idx % 4 === 0 && idx) {
87
- out[ptr++] = bits >> 16 & 255;
88
- out[ptr++] = bits >> 8 & 255;
89
- out[ptr++] = bits & 255;
90
- }
91
- bits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));
92
- }
93
- var tailbits = max % 4 * 6;
94
- if (tailbits === 0) {
8
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
9
+ function base64decode(str) {
10
+ const input = str.replace(/[\r\n=]/g, ""), max = input.length;
11
+ const out = new Uint8Array(max * 3 >> 2);
12
+ let bits = 0;
13
+ let ptr = 0;
14
+ for (let idx = 0; idx < max; idx++) {
15
+ if (idx % 4 === 0 && idx) {
95
16
  out[ptr++] = bits >> 16 & 255;
96
17
  out[ptr++] = bits >> 8 & 255;
97
18
  out[ptr++] = bits & 255;
98
- } else if (tailbits === 18) {
99
- out[ptr++] = bits >> 10 & 255;
100
- out[ptr++] = bits >> 2 & 255;
101
- } else if (tailbits === 12) out[ptr++] = bits >> 4 & 255;
102
- return out;
103
- };
104
- }));
105
- var require_wa_detect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
106
- var wa;
107
- module.exports = function hasWebAssembly() {
108
- if (typeof wa !== "undefined") return wa;
109
- wa = false;
110
- if (typeof WebAssembly === "undefined") return wa;
111
- try {
112
- var bin = new Uint8Array([
113
- 0,
114
- 97,
115
- 115,
116
- 109,
117
- 1,
118
- 0,
119
- 0,
120
- 0,
121
- 1,
122
- 6,
123
- 1,
124
- 96,
125
- 1,
126
- 127,
127
- 1,
128
- 127,
129
- 3,
130
- 2,
131
- 1,
132
- 0,
133
- 5,
134
- 3,
135
- 1,
136
- 0,
137
- 1,
138
- 7,
139
- 8,
140
- 1,
141
- 4,
142
- 116,
143
- 101,
144
- 115,
145
- 116,
146
- 0,
147
- 0,
148
- 10,
149
- 16,
150
- 1,
151
- 14,
152
- 0,
153
- 32,
154
- 0,
155
- 65,
156
- 1,
157
- 54,
158
- 2,
159
- 0,
160
- 32,
161
- 0,
162
- 40,
163
- 2,
164
- 0,
165
- 11
166
- ]);
167
- var module$4 = new WebAssembly.Module(bin);
168
- if (new WebAssembly.Instance(module$4, {}).exports.test(4) !== 0) wa = true;
169
- return wa;
170
- } catch (__) {}
19
+ }
20
+ bits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));
21
+ }
22
+ const tailbits = max % 4 * 6;
23
+ if (tailbits === 0) {
24
+ out[ptr++] = bits >> 16 & 255;
25
+ out[ptr++] = bits >> 8 & 255;
26
+ out[ptr++] = bits & 255;
27
+ } else if (tailbits === 18) {
28
+ out[ptr++] = bits >> 10 & 255;
29
+ out[ptr++] = bits >> 2 & 255;
30
+ } else if (tailbits === 12) out[ptr++] = bits >> 4 & 255;
31
+ return out;
32
+ }
33
+ var wa;
34
+ function hasWebAssembly() {
35
+ if (typeof wa !== "undefined") return wa;
36
+ wa = false;
37
+ if (typeof WebAssembly === "undefined") return wa;
38
+ try {
39
+ const bin = new Uint8Array([
40
+ 0,
41
+ 97,
42
+ 115,
43
+ 109,
44
+ 1,
45
+ 0,
46
+ 0,
47
+ 0,
48
+ 1,
49
+ 6,
50
+ 1,
51
+ 96,
52
+ 1,
53
+ 127,
54
+ 1,
55
+ 127,
56
+ 3,
57
+ 2,
58
+ 1,
59
+ 0,
60
+ 5,
61
+ 3,
62
+ 1,
63
+ 0,
64
+ 1,
65
+ 7,
66
+ 8,
67
+ 1,
68
+ 4,
69
+ 116,
70
+ 101,
71
+ 115,
72
+ 116,
73
+ 0,
74
+ 0,
75
+ 10,
76
+ 16,
77
+ 1,
78
+ 14,
79
+ 0,
80
+ 32,
81
+ 0,
82
+ 65,
83
+ 1,
84
+ 54,
85
+ 2,
86
+ 0,
87
+ 32,
88
+ 0,
89
+ 40,
90
+ 2,
91
+ 0,
92
+ 11
93
+ ]);
94
+ const module = new WebAssembly.Module(bin);
95
+ if (new WebAssembly.Instance(module, {}).exports.test(4) !== 0) wa = true;
171
96
  return wa;
172
- };
173
- }));
174
- var require_multimath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
175
- var assign = require_object_assign();
176
- var base64decode = require_base64decode();
177
- var hasWebAssembly = require_wa_detect();
178
- var DEFAULT_OPTIONS = {
179
- js: true,
180
- wasm: true
181
- };
182
- function MultiMath(options) {
183
- if (!(this instanceof MultiMath)) return new MultiMath(options);
184
- var opts = assign({}, DEFAULT_OPTIONS, options || {});
97
+ } catch (__) {}
98
+ return wa;
99
+ }
100
+ var DEFAULT_OPTIONS = {
101
+ js: true,
102
+ wasm: true
103
+ };
104
+ var MultiMath = class {
105
+ constructor(options) {
106
+ const opts = Object.assign({}, DEFAULT_OPTIONS, options || {});
185
107
  this.options = opts;
186
108
  this.__cache = {};
187
109
  this.__init_promise = null;
@@ -196,47 +118,45 @@ https://github.com/nodeca/pica
196
118
  ]).buffer)[0] === 1;
197
119
  if (!this.options.js && !this.options.wasm) throw new Error("mathlib: at least \"js\" or \"wasm\" should be enabled");
198
120
  }
199
- MultiMath.prototype.has_wasm = hasWebAssembly;
200
- MultiMath.prototype.use = function(module$1) {
201
- this.__modules[module$1.name] = module$1;
202
- if (this.options.wasm && this.has_wasm() && module$1.wasm_fn) this[module$1.name] = module$1.wasm_fn;
203
- else this[module$1.name] = module$1.fn;
121
+ has_wasm() {
122
+ return hasWebAssembly();
123
+ }
124
+ use(module) {
125
+ this.__modules[module.name] = module;
126
+ if (this.options.wasm && this.has_wasm() && module.wasm_fn) this[module.name] = module.wasm_fn;
127
+ else this[module.name] = module.fn;
204
128
  return this;
205
- };
206
- MultiMath.prototype.init = function() {
129
+ }
130
+ init() {
207
131
  if (this.__init_promise) return this.__init_promise;
208
132
  if (!this.options.js && this.options.wasm && !this.has_wasm()) return Promise.reject(/* @__PURE__ */ new Error("mathlib: only \"wasm\" was enabled, but it's not supported"));
209
- var self = this;
210
- this.__init_promise = Promise.all(Object.keys(self.__modules).map(function(name) {
211
- var module$2 = self.__modules[name];
212
- if (!self.options.wasm || !self.has_wasm() || !module$2.wasm_fn) return null;
213
- if (self.__wasm[name]) return null;
214
- return WebAssembly.compile(self.__base64decode(module$2.wasm_src)).then(function(m) {
215
- self.__wasm[name] = m;
133
+ this.__init_promise = Promise.all(Object.keys(this.__modules).map((name) => {
134
+ const module = this.__modules[name];
135
+ if (!this.options.wasm || !this.has_wasm() || !module.wasm_fn) return null;
136
+ if (this.__wasm[name]) return null;
137
+ return WebAssembly.compile(base64decode(module.wasm_src)).then((m) => {
138
+ this.__wasm[name] = m;
216
139
  });
217
- })).then(function() {
218
- return self;
219
- });
140
+ })).then(() => this);
220
141
  return this.__init_promise;
221
- };
222
- MultiMath.prototype.__base64decode = base64decode;
223
- MultiMath.prototype.__reallocate = function mem_grow_to(bytes) {
142
+ }
143
+ __reallocate(bytes) {
224
144
  if (!this.__memory) {
225
145
  this.__memory = new WebAssembly.Memory({ initial: Math.ceil(bytes / (64 * 1024)) });
226
146
  return this.__memory;
227
147
  }
228
- var mem_size = this.__memory.buffer.byteLength;
148
+ const mem_size = this.__memory.buffer.byteLength;
229
149
  if (mem_size < bytes) this.__memory.grow(Math.ceil((bytes - mem_size) / (64 * 1024)));
230
150
  return this.__memory;
231
- };
232
- MultiMath.prototype.__instance = function instance(name, memsize, env_extra) {
151
+ }
152
+ __instance(name, memsize, env_extra) {
233
153
  if (memsize) this.__reallocate(memsize);
234
154
  if (!this.__wasm[name]) {
235
- var module$3 = this.__modules[name];
236
- this.__wasm[name] = new WebAssembly.Module(this.__base64decode(module$3.wasm_src));
155
+ const module = this.__modules[name];
156
+ this.__wasm[name] = new WebAssembly.Module(base64decode(module.wasm_src));
237
157
  }
238
158
  if (!this.__cache[name]) {
239
- var env_base = {
159
+ const env_base = {
240
160
  memoryBase: 0,
241
161
  memory: this.__memory,
242
162
  tableBase: 0,
@@ -245,100 +165,93 @@ https://github.com/nodeca/pica
245
165
  element: "anyfunc"
246
166
  })
247
167
  };
248
- this.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: assign(env_base, env_extra || {}) });
168
+ this.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: Object.assign(env_base, env_extra || {}) });
249
169
  }
250
170
  return this.__cache[name];
251
- };
252
- MultiMath.prototype.__align = function align(number, base) {
171
+ }
172
+ __align(number, base) {
253
173
  base = base || 8;
254
- var reminder = number % base;
174
+ const reminder = number % base;
255
175
  return number + (reminder ? base - reminder : 0);
256
- };
257
- module.exports = MultiMath;
258
- }));
259
- var require_mono16 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
260
- var a0, a1, a2, a3, b1, b2, left_corner, right_corner;
261
- function gaussCoef(sigma) {
262
- if (sigma < .5) sigma = .5;
263
- var a = Math.exp(.726 * .726) / sigma, g1 = Math.exp(-a), g2 = Math.exp(-2 * a), k = (1 - g1) * (1 - g1) / (1 + 2 * a * g1 - g2);
264
- a0 = k;
265
- a1 = k * (a - 1) * g1;
266
- a2 = k * (a + 1) * g1;
267
- a3 = -k * g2;
268
- b1 = 2 * g1;
269
- b2 = -g2;
270
- left_corner = (a0 + a1) / (1 - b1 - b2);
271
- right_corner = (a2 + a3) / (1 - b1 - b2);
272
- return new Float32Array([
273
- a0,
274
- a1,
275
- a2,
276
- a3,
277
- b1,
278
- b2,
279
- left_corner,
280
- right_corner
281
- ]);
282
176
  }
283
- function convolveMono16(src, out, line, coeff, width, height) {
284
- var prev_src, curr_src, curr_out, prev_out, prev_prev_out;
285
- var src_index, out_index, line_index;
286
- var i, j;
287
- var coeff_a0, coeff_a1, coeff_b1, coeff_b2;
288
- for (i = 0; i < height; i++) {
289
- src_index = i * width;
290
- out_index = i;
291
- line_index = 0;
292
- prev_src = src[src_index];
293
- prev_prev_out = prev_src * coeff[6];
294
- prev_out = prev_prev_out;
295
- coeff_a0 = coeff[0];
296
- coeff_a1 = coeff[1];
297
- coeff_b1 = coeff[4];
298
- coeff_b2 = coeff[5];
299
- for (j = 0; j < width; j++) {
300
- curr_src = src[src_index];
301
- curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
302
- prev_prev_out = prev_out;
303
- prev_out = curr_out;
304
- prev_src = curr_src;
305
- line[line_index] = prev_out;
306
- line_index++;
307
- src_index++;
308
- }
177
+ };
178
+ function gaussCoef(sigma) {
179
+ if (sigma < .5) sigma = .5;
180
+ const a = Math.exp(.726 * .726) / sigma, g1 = Math.exp(-a), g2 = Math.exp(-2 * a), k = (1 - g1) * (1 - g1) / (1 + 2 * a * g1 - g2);
181
+ const a0 = k;
182
+ const a1 = k * (a - 1) * g1;
183
+ const a2 = k * (a + 1) * g1;
184
+ const a3 = -k * g2;
185
+ const b1 = 2 * g1;
186
+ const b2 = -g2;
187
+ const left_corner = (a0 + a1) / (1 - b1 - b2);
188
+ const right_corner = (a2 + a3) / (1 - b1 - b2);
189
+ return new Float32Array([
190
+ a0,
191
+ a1,
192
+ a2,
193
+ a3,
194
+ b1,
195
+ b2,
196
+ left_corner,
197
+ right_corner
198
+ ]);
199
+ }
200
+ function convolveMono16(src, out, line, coeff, width, height) {
201
+ let prev_src, curr_src, curr_out, prev_out, prev_prev_out;
202
+ let src_index, out_index, line_index;
203
+ let i, j;
204
+ let coeff_a0, coeff_a1, coeff_b1, coeff_b2;
205
+ for (i = 0; i < height; i++) {
206
+ src_index = i * width;
207
+ out_index = i;
208
+ line_index = 0;
209
+ prev_src = src[src_index];
210
+ prev_prev_out = prev_src * coeff[6];
211
+ prev_out = prev_prev_out;
212
+ coeff_a0 = coeff[0];
213
+ coeff_a1 = coeff[1];
214
+ coeff_b1 = coeff[4];
215
+ coeff_b2 = coeff[5];
216
+ for (j = 0; j < width; j++) {
217
+ curr_src = src[src_index];
218
+ curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
219
+ prev_prev_out = prev_out;
220
+ prev_out = curr_out;
221
+ prev_src = curr_src;
222
+ line[line_index] = prev_out;
223
+ line_index++;
224
+ src_index++;
225
+ }
226
+ src_index--;
227
+ line_index--;
228
+ out_index += height * (width - 1);
229
+ prev_src = src[src_index];
230
+ prev_prev_out = prev_src * coeff[7];
231
+ prev_out = prev_prev_out;
232
+ curr_src = prev_src;
233
+ coeff_a0 = coeff[2];
234
+ coeff_a1 = coeff[3];
235
+ for (j = width - 1; j >= 0; j--) {
236
+ curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
237
+ prev_prev_out = prev_out;
238
+ prev_out = curr_out;
239
+ prev_src = curr_src;
240
+ curr_src = src[src_index];
241
+ out[out_index] = line[line_index] + prev_out;
309
242
  src_index--;
310
243
  line_index--;
311
- out_index += height * (width - 1);
312
- prev_src = src[src_index];
313
- prev_prev_out = prev_src * coeff[7];
314
- prev_out = prev_prev_out;
315
- curr_src = prev_src;
316
- coeff_a0 = coeff[2];
317
- coeff_a1 = coeff[3];
318
- for (j = width - 1; j >= 0; j--) {
319
- curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
320
- prev_prev_out = prev_out;
321
- prev_out = curr_out;
322
- prev_src = curr_src;
323
- curr_src = src[src_index];
324
- out[out_index] = line[line_index] + prev_out;
325
- src_index--;
326
- line_index--;
327
- out_index -= height;
328
- }
244
+ out_index -= height;
329
245
  }
330
246
  }
331
- function blurMono16(src, width, height, radius) {
332
- if (!radius) return;
333
- var out = new Uint16Array(src.length), tmp_line = new Float32Array(Math.max(width, height));
334
- var coeff = gaussCoef(radius);
335
- convolveMono16(src, out, tmp_line, coeff, width, height, radius);
336
- convolveMono16(out, src, tmp_line, coeff, height, width, radius);
337
- }
338
- module.exports = blurMono16;
339
- }));
340
- var import_multimath = /* @__PURE__ */ __toESM(require_multimath());
341
- var import_mono16 = /* @__PURE__ */ __toESM(require_mono16());
247
+ }
248
+ function blurMono16(src, width, height, radius) {
249
+ if (!radius) return;
250
+ const out = new Uint16Array(src.length), tmp_line = new Float32Array(Math.max(width, height));
251
+ const coeff = gaussCoef(radius);
252
+ convolveMono16(src, out, tmp_line, coeff, width, height, radius);
253
+ convolveMono16(out, src, tmp_line, coeff, height, width, radius);
254
+ }
342
255
  function hsv_v16(img, width, height) {
343
256
  const size = width * height;
344
257
  const out = new Uint16Array(size);
@@ -359,7 +272,7 @@ https://github.com/nodeca/pica
359
272
  if (radius > 2) radius = 2;
360
273
  const brightness = hsv_v16(img, width, height);
361
274
  const blured = new Uint16Array(brightness);
362
- (0, import_mono16.default)(blured, width, height, radius);
275
+ blurMono16(blured, width, height, radius);
363
276
  const amountFp = amount / 100 * 4096 + .5 | 0;
364
277
  const thresholdFp = threshold << 8;
365
278
  const size = width * height;
@@ -786,7 +699,7 @@ https://github.com/nodeca/pica
786
699
  wasm_fn: resize_wasm,
787
700
  wasm_src: "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"
788
701
  };
789
- var MathLib = class extends import_multimath.default {
702
+ var MathLib = class extends MultiMath {
790
703
  constructor(requested_features) {
791
704
  const __requested_features = requested_features || [];
792
705
  const features = {
@@ -820,13 +733,14 @@ https://github.com/nodeca/pica
820
733
  };
821
734
  var checked = false;
822
735
  var checking = null;
736
+ var ctxOpts = { willReadFrequently: true };
823
737
  function check_canvas() {
824
738
  if (typeof document === "undefined" || !document.createElement) return false;
825
739
  try {
826
740
  const canvas = document.createElement("canvas");
827
741
  canvas.width = 2;
828
742
  canvas.height = 1;
829
- const ctx = canvas.getContext("2d");
743
+ const ctx = canvas.getContext("2d", ctxOpts);
830
744
  let d = ctx.createImageData(2, 1);
831
745
  d.data[0] = 12;
832
746
  d.data[1] = 23;
@@ -846,7 +760,7 @@ https://github.com/nodeca/pica
846
760
  function check_offscreen_canvas() {
847
761
  if (typeof OffscreenCanvas === "undefined") return false;
848
762
  try {
849
- const ctx = new OffscreenCanvas(2, 1).getContext("2d");
763
+ const ctx = new OffscreenCanvas(2, 1).getContext("2d", ctxOpts);
850
764
  let d = ctx.createImageData(2, 1);
851
765
  d.data[0] = 12;
852
766
  d.data[1] = 23;
@@ -885,7 +799,7 @@ https://github.com/nodeca/pica
885
799
  return createImageBitmap(new Blob([bytes], { type: "image/jpeg" })).then((bitmap) => {
886
800
  const canvas = new OffscreenCanvas(1, 1);
887
801
  try {
888
- const ctx = canvas.getContext("2d");
802
+ const ctx = canvas.getContext("2d", ctxOpts);
889
803
  ctx.drawImage(bitmap, 1, 1, 1, 1, 0, 0, 1, 1);
890
804
  return ctx.getImageData(0, 0, 1, 1).data[0] < 240;
891
805
  } finally {
@@ -900,7 +814,7 @@ https://github.com/nodeca/pica
900
814
  const canvas = document.createElement("canvas");
901
815
  canvas.width = 1;
902
816
  canvas.height = 1;
903
- const ctx = canvas.getContext("2d");
817
+ const ctx = canvas.getContext("2d", ctxOpts);
904
818
  ctx.drawImage(image, 1, 1, 1, 1, 0, 0, 1, 1);
905
819
  resolve(ctx.getImageData(0, 0, 1, 1).data[0] < 240);
906
820
  } catch (__) {
@@ -932,7 +846,7 @@ https://github.com/nodeca/pica
932
846
  canvas.height = 1;
933
847
  }
934
848
  try {
935
- const ctx = canvas.getContext("2d");
849
+ const ctx = canvas.getContext("2d", ctxOpts);
936
850
  ctx.drawImage(bitmap, 0, 0);
937
851
  return bitmap.width !== 1 || bitmap.height !== 1 || ctx.getImageData(0, 0, 1, 1).data[0] < 240;
938
852
  } finally {
@@ -957,7 +871,7 @@ https://github.com/nodeca/pica
957
871
  canvas.height = SRC_SIZE;
958
872
  } else if (features.offscreen_canvas || check_offscreen_canvas()) {
959
873
  canvas = new OffscreenCanvas(SRC_SIZE, SRC_SIZE);
960
- canvas.getContext("2d").clearRect(0, 0, SRC_SIZE, SRC_SIZE);
874
+ canvas.getContext("2d", ctxOpts).clearRect(0, 0, SRC_SIZE, SRC_SIZE);
961
875
  } else return false;
962
876
  return createImageBitmap(canvas, 0, 0, SRC_SIZE, SRC_SIZE, {
963
877
  resizeWidth: DST_SIZE,
@@ -1010,7 +924,8 @@ https://github.com/nodeca/pica
1010
924
  }
1011
925
  function resizeBitmap(data, tileJob) {
1012
926
  let srcCanvas = new OffscreenCanvas(tileJob.width, tileJob.height);
1013
- const srcCtx = srcCanvas.getContext("2d");
927
+ const ctxOpts = { willReadFrequently: true };
928
+ const srcCtx = srcCanvas.getContext("2d", ctxOpts);
1014
929
  srcCtx.drawImage(tileJob.src, 0, 0);
1015
930
  const src = srcCtx.getImageData(0, 0, tileJob.width, tileJob.height).data;
1016
931
  srcCanvas.width = srcCanvas.height = 0;
@@ -1032,7 +947,7 @@ https://github.com/nodeca/pica
1032
947
  unsharpThreshold: tileJob.unsharpThreshold
1033
948
  });
1034
949
  const canvas = new OffscreenCanvas(tileJob.toWidth, tileJob.toHeight);
1035
- const ctx = canvas.getContext("2d");
950
+ const ctx = canvas.getContext("2d", ctxOpts);
1036
951
  const toImageData = ctx.createImageData(tileJob.toWidth, tileJob.toHeight);
1037
952
  toImageData.data.set(result);
1038
953
  ctx.putImageData(toImageData, 0, 0);