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.
@@ -4,183 +4,105 @@ pica
4
4
  https://github.com/nodeca/pica
5
5
 
6
6
  */
7
- var __create = Object.create;
8
- var __defProp = Object.defineProperty;
9
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
- var __getOwnPropNames = Object.getOwnPropertyNames;
11
- var __getProtoOf = Object.getPrototypeOf;
12
- var __hasOwnProp = Object.prototype.hasOwnProperty;
13
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
14
- var __copyProps = (to, from, except, desc) => {
15
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
16
- key = keys[i];
17
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
- get: ((k) => from[k]).bind(null, key),
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
- value: mod,
26
- enumerable: true
27
- }) : target, mod));
28
- /*
29
- object-assign
30
- (c) Sindre Sorhus
31
- @license MIT
32
- */
33
- var require_object_assign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
34
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
35
- var hasOwnProperty = Object.prototype.hasOwnProperty;
36
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
37
- function toObject(val) {
38
- if (val === null || val === void 0) throw new TypeError("Object.assign cannot be called with null or undefined");
39
- return Object(val);
40
- }
41
- function shouldUseNative() {
42
- try {
43
- if (!Object.assign) return false;
44
- var test1 = /* @__PURE__ */ new String("abc");
45
- test1[5] = "de";
46
- if (Object.getOwnPropertyNames(test1)[0] === "5") return false;
47
- var test2 = {};
48
- for (var i = 0; i < 10; i++) test2["_" + String.fromCharCode(i)] = i;
49
- if (Object.getOwnPropertyNames(test2).map(function(n) {
50
- return test2[n];
51
- }).join("") !== "0123456789") return false;
52
- var test3 = {};
53
- "abcdefghijklmnopqrst".split("").forEach(function(letter) {
54
- test3[letter] = letter;
55
- });
56
- if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") return false;
57
- return true;
58
- } catch (err) {
59
- return false;
60
- }
61
- }
62
- module.exports = shouldUseNative() ? Object.assign : function(target, source) {
63
- var from;
64
- var to = toObject(target);
65
- var symbols;
66
- for (var s = 1; s < arguments.length; s++) {
67
- from = Object(arguments[s]);
68
- for (var key in from) if (hasOwnProperty.call(from, key)) to[key] = from[key];
69
- if (getOwnPropertySymbols) {
70
- symbols = getOwnPropertySymbols(from);
71
- for (var i = 0; i < symbols.length; i++) if (propIsEnumerable.call(from, symbols[i])) to[symbols[i]] = from[symbols[i]];
72
- }
73
- }
74
- return to;
75
- };
76
- }));
77
- var require_base64decode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
78
- var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
79
- module.exports = function base64decode(str) {
80
- var input = str.replace(/[\r\n=]/g, ""), max = input.length;
81
- var out = new Uint8Array(max * 3 >> 2);
82
- var bits = 0;
83
- var ptr = 0;
84
- for (var idx = 0; idx < max; idx++) {
85
- if (idx % 4 === 0 && idx) {
86
- out[ptr++] = bits >> 16 & 255;
87
- out[ptr++] = bits >> 8 & 255;
88
- out[ptr++] = bits & 255;
89
- }
90
- bits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));
91
- }
92
- var tailbits = max % 4 * 6;
93
- if (tailbits === 0) {
7
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
8
+ function base64decode(str) {
9
+ const input = str.replace(/[\r\n=]/g, ""), max = input.length;
10
+ const out = new Uint8Array(max * 3 >> 2);
11
+ let bits = 0;
12
+ let ptr = 0;
13
+ for (let idx = 0; idx < max; idx++) {
14
+ if (idx % 4 === 0 && idx) {
94
15
  out[ptr++] = bits >> 16 & 255;
95
16
  out[ptr++] = bits >> 8 & 255;
96
17
  out[ptr++] = bits & 255;
97
- } else if (tailbits === 18) {
98
- out[ptr++] = bits >> 10 & 255;
99
- out[ptr++] = bits >> 2 & 255;
100
- } else if (tailbits === 12) out[ptr++] = bits >> 4 & 255;
101
- return out;
102
- };
103
- }));
104
- var require_wa_detect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
105
- var wa;
106
- module.exports = function hasWebAssembly() {
107
- if (typeof wa !== "undefined") return wa;
108
- wa = false;
109
- if (typeof WebAssembly === "undefined") return wa;
110
- try {
111
- var bin = new Uint8Array([
112
- 0,
113
- 97,
114
- 115,
115
- 109,
116
- 1,
117
- 0,
118
- 0,
119
- 0,
120
- 1,
121
- 6,
122
- 1,
123
- 96,
124
- 1,
125
- 127,
126
- 1,
127
- 127,
128
- 3,
129
- 2,
130
- 1,
131
- 0,
132
- 5,
133
- 3,
134
- 1,
135
- 0,
136
- 1,
137
- 7,
138
- 8,
139
- 1,
140
- 4,
141
- 116,
142
- 101,
143
- 115,
144
- 116,
145
- 0,
146
- 0,
147
- 10,
148
- 16,
149
- 1,
150
- 14,
151
- 0,
152
- 32,
153
- 0,
154
- 65,
155
- 1,
156
- 54,
157
- 2,
158
- 0,
159
- 32,
160
- 0,
161
- 40,
162
- 2,
163
- 0,
164
- 11
165
- ]);
166
- var module$4 = new WebAssembly.Module(bin);
167
- if (new WebAssembly.Instance(module$4, {}).exports.test(4) !== 0) wa = true;
168
- return wa;
169
- } catch (__) {}
18
+ }
19
+ bits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));
20
+ }
21
+ const tailbits = max % 4 * 6;
22
+ if (tailbits === 0) {
23
+ out[ptr++] = bits >> 16 & 255;
24
+ out[ptr++] = bits >> 8 & 255;
25
+ out[ptr++] = bits & 255;
26
+ } else if (tailbits === 18) {
27
+ out[ptr++] = bits >> 10 & 255;
28
+ out[ptr++] = bits >> 2 & 255;
29
+ } else if (tailbits === 12) out[ptr++] = bits >> 4 & 255;
30
+ return out;
31
+ }
32
+ var wa;
33
+ function hasWebAssembly() {
34
+ if (typeof wa !== "undefined") return wa;
35
+ wa = false;
36
+ if (typeof WebAssembly === "undefined") return wa;
37
+ try {
38
+ const bin = new Uint8Array([
39
+ 0,
40
+ 97,
41
+ 115,
42
+ 109,
43
+ 1,
44
+ 0,
45
+ 0,
46
+ 0,
47
+ 1,
48
+ 6,
49
+ 1,
50
+ 96,
51
+ 1,
52
+ 127,
53
+ 1,
54
+ 127,
55
+ 3,
56
+ 2,
57
+ 1,
58
+ 0,
59
+ 5,
60
+ 3,
61
+ 1,
62
+ 0,
63
+ 1,
64
+ 7,
65
+ 8,
66
+ 1,
67
+ 4,
68
+ 116,
69
+ 101,
70
+ 115,
71
+ 116,
72
+ 0,
73
+ 0,
74
+ 10,
75
+ 16,
76
+ 1,
77
+ 14,
78
+ 0,
79
+ 32,
80
+ 0,
81
+ 65,
82
+ 1,
83
+ 54,
84
+ 2,
85
+ 0,
86
+ 32,
87
+ 0,
88
+ 40,
89
+ 2,
90
+ 0,
91
+ 11
92
+ ]);
93
+ const module = new WebAssembly.Module(bin);
94
+ if (new WebAssembly.Instance(module, {}).exports.test(4) !== 0) wa = true;
170
95
  return wa;
171
- };
172
- }));
173
- var require_multimath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
174
- var assign = require_object_assign();
175
- var base64decode = require_base64decode();
176
- var hasWebAssembly = require_wa_detect();
177
- var DEFAULT_OPTIONS = {
178
- js: true,
179
- wasm: true
180
- };
181
- function MultiMath(options) {
182
- if (!(this instanceof MultiMath)) return new MultiMath(options);
183
- var opts = assign({}, DEFAULT_OPTIONS, options || {});
96
+ } catch (__) {}
97
+ return wa;
98
+ }
99
+ var DEFAULT_OPTIONS = {
100
+ js: true,
101
+ wasm: true
102
+ };
103
+ var MultiMath = class {
104
+ constructor(options) {
105
+ const opts = Object.assign({}, DEFAULT_OPTIONS, options || {});
184
106
  this.options = opts;
185
107
  this.__cache = {};
186
108
  this.__init_promise = null;
@@ -195,47 +117,45 @@ var require_multimath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
195
117
  ]).buffer)[0] === 1;
196
118
  if (!this.options.js && !this.options.wasm) throw new Error("mathlib: at least \"js\" or \"wasm\" should be enabled");
197
119
  }
198
- MultiMath.prototype.has_wasm = hasWebAssembly;
199
- MultiMath.prototype.use = function(module$1) {
200
- this.__modules[module$1.name] = module$1;
201
- if (this.options.wasm && this.has_wasm() && module$1.wasm_fn) this[module$1.name] = module$1.wasm_fn;
202
- else this[module$1.name] = module$1.fn;
120
+ has_wasm() {
121
+ return hasWebAssembly();
122
+ }
123
+ use(module) {
124
+ this.__modules[module.name] = module;
125
+ if (this.options.wasm && this.has_wasm() && module.wasm_fn) this[module.name] = module.wasm_fn;
126
+ else this[module.name] = module.fn;
203
127
  return this;
204
- };
205
- MultiMath.prototype.init = function() {
128
+ }
129
+ init() {
206
130
  if (this.__init_promise) return this.__init_promise;
207
131
  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"));
208
- var self = this;
209
- this.__init_promise = Promise.all(Object.keys(self.__modules).map(function(name) {
210
- var module$2 = self.__modules[name];
211
- if (!self.options.wasm || !self.has_wasm() || !module$2.wasm_fn) return null;
212
- if (self.__wasm[name]) return null;
213
- return WebAssembly.compile(self.__base64decode(module$2.wasm_src)).then(function(m) {
214
- self.__wasm[name] = m;
132
+ this.__init_promise = Promise.all(Object.keys(this.__modules).map((name) => {
133
+ const module = this.__modules[name];
134
+ if (!this.options.wasm || !this.has_wasm() || !module.wasm_fn) return null;
135
+ if (this.__wasm[name]) return null;
136
+ return WebAssembly.compile(base64decode(module.wasm_src)).then((m) => {
137
+ this.__wasm[name] = m;
215
138
  });
216
- })).then(function() {
217
- return self;
218
- });
139
+ })).then(() => this);
219
140
  return this.__init_promise;
220
- };
221
- MultiMath.prototype.__base64decode = base64decode;
222
- MultiMath.prototype.__reallocate = function mem_grow_to(bytes) {
141
+ }
142
+ __reallocate(bytes) {
223
143
  if (!this.__memory) {
224
144
  this.__memory = new WebAssembly.Memory({ initial: Math.ceil(bytes / (64 * 1024)) });
225
145
  return this.__memory;
226
146
  }
227
- var mem_size = this.__memory.buffer.byteLength;
147
+ const mem_size = this.__memory.buffer.byteLength;
228
148
  if (mem_size < bytes) this.__memory.grow(Math.ceil((bytes - mem_size) / (64 * 1024)));
229
149
  return this.__memory;
230
- };
231
- MultiMath.prototype.__instance = function instance(name, memsize, env_extra) {
150
+ }
151
+ __instance(name, memsize, env_extra) {
232
152
  if (memsize) this.__reallocate(memsize);
233
153
  if (!this.__wasm[name]) {
234
- var module$3 = this.__modules[name];
235
- this.__wasm[name] = new WebAssembly.Module(this.__base64decode(module$3.wasm_src));
154
+ const module = this.__modules[name];
155
+ this.__wasm[name] = new WebAssembly.Module(base64decode(module.wasm_src));
236
156
  }
237
157
  if (!this.__cache[name]) {
238
- var env_base = {
158
+ const env_base = {
239
159
  memoryBase: 0,
240
160
  memory: this.__memory,
241
161
  tableBase: 0,
@@ -244,100 +164,93 @@ var require_multimath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
244
164
  element: "anyfunc"
245
165
  })
246
166
  };
247
- this.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: assign(env_base, env_extra || {}) });
167
+ this.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: Object.assign(env_base, env_extra || {}) });
248
168
  }
249
169
  return this.__cache[name];
250
- };
251
- MultiMath.prototype.__align = function align(number, base) {
170
+ }
171
+ __align(number, base) {
252
172
  base = base || 8;
253
- var reminder = number % base;
173
+ const reminder = number % base;
254
174
  return number + (reminder ? base - reminder : 0);
255
- };
256
- module.exports = MultiMath;
257
- }));
258
- var require_mono16 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
259
- var a0, a1, a2, a3, b1, b2, left_corner, right_corner;
260
- function gaussCoef(sigma) {
261
- if (sigma < .5) sigma = .5;
262
- 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);
263
- a0 = k;
264
- a1 = k * (a - 1) * g1;
265
- a2 = k * (a + 1) * g1;
266
- a3 = -k * g2;
267
- b1 = 2 * g1;
268
- b2 = -g2;
269
- left_corner = (a0 + a1) / (1 - b1 - b2);
270
- right_corner = (a2 + a3) / (1 - b1 - b2);
271
- return new Float32Array([
272
- a0,
273
- a1,
274
- a2,
275
- a3,
276
- b1,
277
- b2,
278
- left_corner,
279
- right_corner
280
- ]);
281
175
  }
282
- function convolveMono16(src, out, line, coeff, width, height) {
283
- var prev_src, curr_src, curr_out, prev_out, prev_prev_out;
284
- var src_index, out_index, line_index;
285
- var i, j;
286
- var coeff_a0, coeff_a1, coeff_b1, coeff_b2;
287
- for (i = 0; i < height; i++) {
288
- src_index = i * width;
289
- out_index = i;
290
- line_index = 0;
291
- prev_src = src[src_index];
292
- prev_prev_out = prev_src * coeff[6];
293
- prev_out = prev_prev_out;
294
- coeff_a0 = coeff[0];
295
- coeff_a1 = coeff[1];
296
- coeff_b1 = coeff[4];
297
- coeff_b2 = coeff[5];
298
- for (j = 0; j < width; j++) {
299
- curr_src = src[src_index];
300
- curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
301
- prev_prev_out = prev_out;
302
- prev_out = curr_out;
303
- prev_src = curr_src;
304
- line[line_index] = prev_out;
305
- line_index++;
306
- src_index++;
307
- }
176
+ };
177
+ function gaussCoef(sigma) {
178
+ if (sigma < .5) sigma = .5;
179
+ 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);
180
+ const a0 = k;
181
+ const a1 = k * (a - 1) * g1;
182
+ const a2 = k * (a + 1) * g1;
183
+ const a3 = -k * g2;
184
+ const b1 = 2 * g1;
185
+ const b2 = -g2;
186
+ const left_corner = (a0 + a1) / (1 - b1 - b2);
187
+ const right_corner = (a2 + a3) / (1 - b1 - b2);
188
+ return new Float32Array([
189
+ a0,
190
+ a1,
191
+ a2,
192
+ a3,
193
+ b1,
194
+ b2,
195
+ left_corner,
196
+ right_corner
197
+ ]);
198
+ }
199
+ function convolveMono16(src, out, line, coeff, width, height) {
200
+ let prev_src, curr_src, curr_out, prev_out, prev_prev_out;
201
+ let src_index, out_index, line_index;
202
+ let i, j;
203
+ let coeff_a0, coeff_a1, coeff_b1, coeff_b2;
204
+ for (i = 0; i < height; i++) {
205
+ src_index = i * width;
206
+ out_index = i;
207
+ line_index = 0;
208
+ prev_src = src[src_index];
209
+ prev_prev_out = prev_src * coeff[6];
210
+ prev_out = prev_prev_out;
211
+ coeff_a0 = coeff[0];
212
+ coeff_a1 = coeff[1];
213
+ coeff_b1 = coeff[4];
214
+ coeff_b2 = coeff[5];
215
+ for (j = 0; j < width; j++) {
216
+ curr_src = src[src_index];
217
+ curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
218
+ prev_prev_out = prev_out;
219
+ prev_out = curr_out;
220
+ prev_src = curr_src;
221
+ line[line_index] = prev_out;
222
+ line_index++;
223
+ src_index++;
224
+ }
225
+ src_index--;
226
+ line_index--;
227
+ out_index += height * (width - 1);
228
+ prev_src = src[src_index];
229
+ prev_prev_out = prev_src * coeff[7];
230
+ prev_out = prev_prev_out;
231
+ curr_src = prev_src;
232
+ coeff_a0 = coeff[2];
233
+ coeff_a1 = coeff[3];
234
+ for (j = width - 1; j >= 0; j--) {
235
+ curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
236
+ prev_prev_out = prev_out;
237
+ prev_out = curr_out;
238
+ prev_src = curr_src;
239
+ curr_src = src[src_index];
240
+ out[out_index] = line[line_index] + prev_out;
308
241
  src_index--;
309
242
  line_index--;
310
- out_index += height * (width - 1);
311
- prev_src = src[src_index];
312
- prev_prev_out = prev_src * coeff[7];
313
- prev_out = prev_prev_out;
314
- curr_src = prev_src;
315
- coeff_a0 = coeff[2];
316
- coeff_a1 = coeff[3];
317
- for (j = width - 1; j >= 0; j--) {
318
- curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
319
- prev_prev_out = prev_out;
320
- prev_out = curr_out;
321
- prev_src = curr_src;
322
- curr_src = src[src_index];
323
- out[out_index] = line[line_index] + prev_out;
324
- src_index--;
325
- line_index--;
326
- out_index -= height;
327
- }
243
+ out_index -= height;
328
244
  }
329
245
  }
330
- function blurMono16(src, width, height, radius) {
331
- if (!radius) return;
332
- var out = new Uint16Array(src.length), tmp_line = new Float32Array(Math.max(width, height));
333
- var coeff = gaussCoef(radius);
334
- convolveMono16(src, out, tmp_line, coeff, width, height, radius);
335
- convolveMono16(out, src, tmp_line, coeff, height, width, radius);
336
- }
337
- module.exports = blurMono16;
338
- }));
339
- var import_multimath = /* @__PURE__ */ __toESM(require_multimath());
340
- var import_mono16 = /* @__PURE__ */ __toESM(require_mono16());
246
+ }
247
+ function blurMono16(src, width, height, radius) {
248
+ if (!radius) return;
249
+ const out = new Uint16Array(src.length), tmp_line = new Float32Array(Math.max(width, height));
250
+ const coeff = gaussCoef(radius);
251
+ convolveMono16(src, out, tmp_line, coeff, width, height, radius);
252
+ convolveMono16(out, src, tmp_line, coeff, height, width, radius);
253
+ }
341
254
  function hsv_v16(img, width, height) {
342
255
  const size = width * height;
343
256
  const out = new Uint16Array(size);
@@ -358,7 +271,7 @@ function unsharp$1(img, width, height, amount, radius, threshold) {
358
271
  if (radius > 2) radius = 2;
359
272
  const brightness = hsv_v16(img, width, height);
360
273
  const blured = new Uint16Array(brightness);
361
- (0, import_mono16.default)(blured, width, height, radius);
274
+ blurMono16(blured, width, height, radius);
362
275
  const amountFp = amount / 100 * 4096 + .5 | 0;
363
276
  const thresholdFp = threshold << 8;
364
277
  const size = width * height;
@@ -785,7 +698,7 @@ var mm_resize_default = {
785
698
  wasm_fn: resize_wasm,
786
699
  wasm_src: "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"
787
700
  };
788
- var MathLib = class extends import_multimath.default {
701
+ var MathLib = class extends MultiMath {
789
702
  constructor(requested_features) {
790
703
  const __requested_features = requested_features || [];
791
704
  const features = {
@@ -1052,13 +965,14 @@ var features = {
1052
965
  };
1053
966
  var checked = false;
1054
967
  var checking = null;
968
+ var ctxOpts$1 = { willReadFrequently: true };
1055
969
  function check_canvas() {
1056
970
  if (typeof document === "undefined" || !document.createElement) return false;
1057
971
  try {
1058
972
  const canvas = document.createElement("canvas");
1059
973
  canvas.width = 2;
1060
974
  canvas.height = 1;
1061
- const ctx = canvas.getContext("2d");
975
+ const ctx = canvas.getContext("2d", ctxOpts$1);
1062
976
  let d = ctx.createImageData(2, 1);
1063
977
  d.data[0] = 12;
1064
978
  d.data[1] = 23;
@@ -1078,7 +992,7 @@ function check_canvas() {
1078
992
  function check_offscreen_canvas() {
1079
993
  if (typeof OffscreenCanvas === "undefined") return false;
1080
994
  try {
1081
- const ctx = new OffscreenCanvas(2, 1).getContext("2d");
995
+ const ctx = new OffscreenCanvas(2, 1).getContext("2d", ctxOpts$1);
1082
996
  let d = ctx.createImageData(2, 1);
1083
997
  d.data[0] = 12;
1084
998
  d.data[1] = 23;
@@ -1117,7 +1031,7 @@ function check_bug_canvas_orientation_region_async() {
1117
1031
  return createImageBitmap(new Blob([bytes], { type: "image/jpeg" })).then((bitmap) => {
1118
1032
  const canvas = new OffscreenCanvas(1, 1);
1119
1033
  try {
1120
- const ctx = canvas.getContext("2d");
1034
+ const ctx = canvas.getContext("2d", ctxOpts$1);
1121
1035
  ctx.drawImage(bitmap, 1, 1, 1, 1, 0, 0, 1, 1);
1122
1036
  return ctx.getImageData(0, 0, 1, 1).data[0] < 240;
1123
1037
  } finally {
@@ -1132,7 +1046,7 @@ function check_bug_canvas_orientation_region_async() {
1132
1046
  const canvas = document.createElement("canvas");
1133
1047
  canvas.width = 1;
1134
1048
  canvas.height = 1;
1135
- const ctx = canvas.getContext("2d");
1049
+ const ctx = canvas.getContext("2d", ctxOpts$1);
1136
1050
  ctx.drawImage(image, 1, 1, 1, 1, 0, 0, 1, 1);
1137
1051
  resolve(ctx.getImageData(0, 0, 1, 1).data[0] < 240);
1138
1052
  } catch (__) {
@@ -1164,7 +1078,7 @@ function check_bug_image_bitmap_orientation_region_async() {
1164
1078
  canvas.height = 1;
1165
1079
  }
1166
1080
  try {
1167
- const ctx = canvas.getContext("2d");
1081
+ const ctx = canvas.getContext("2d", ctxOpts$1);
1168
1082
  ctx.drawImage(bitmap, 0, 0);
1169
1083
  return bitmap.width !== 1 || bitmap.height !== 1 || ctx.getImageData(0, 0, 1, 1).data[0] < 240;
1170
1084
  } finally {
@@ -1189,7 +1103,7 @@ function check_cib_resize_async() {
1189
1103
  canvas.height = SRC_SIZE;
1190
1104
  } else if (features.offscreen_canvas || check_offscreen_canvas()) {
1191
1105
  canvas = new OffscreenCanvas(SRC_SIZE, SRC_SIZE);
1192
- canvas.getContext("2d").clearRect(0, 0, SRC_SIZE, SRC_SIZE);
1106
+ canvas.getContext("2d", ctxOpts$1).clearRect(0, 0, SRC_SIZE, SRC_SIZE);
1193
1107
  } else return false;
1194
1108
  return createImageBitmap(canvas, 0, 0, SRC_SIZE, SRC_SIZE, {
1195
1109
  resizeWidth: DST_SIZE,
@@ -1276,6 +1190,7 @@ var DEFAULT_RESIZE_OPTS = {
1276
1190
  unsharpRadius: 0,
1277
1191
  unsharpThreshold: 0
1278
1192
  };
1193
+ var ctxOpts = { willReadFrequently: true };
1279
1194
  var Pica = class {
1280
1195
  constructor(options) {
1281
1196
  _defineProperty(this, "options", void 0);
@@ -1420,7 +1335,7 @@ var Pica = class {
1420
1335
  if (this.resize_features.ww && this.capabilities.ww_offscreen_canvas) {
1421
1336
  this.debug("Create tile imageBitmap");
1422
1337
  const tileCanvas = this.createCanvas(tile.width, tile.height, { preferOffscreen: true });
1423
- tileCanvas.getContext("2d").drawImage(stageEnv.srcImageBitmap || from, tile.x, tile.y, tile.width, tile.height, 0, 0, tile.width, tile.height);
1338
+ tileCanvas.getContext("2d", ctxOpts).drawImage(stageEnv.srcImageBitmap || from, tile.x, tile.y, tile.width, tile.height, 0, 0, tile.width, tile.height);
1424
1339
  if (!("transferToImageBitmap" in tileCanvas)) throw new Error("Pica: offscreen canvas is not available for worker transfer");
1425
1340
  return Object.assign({}, extractTo, {
1426
1341
  kind: "bitmap",
@@ -1428,7 +1343,7 @@ var Pica = class {
1428
1343
  });
1429
1344
  }
1430
1345
  if (isCanvas(from)) {
1431
- if (!stageEnv.srcCtx) stageEnv.srcCtx = from.getContext("2d");
1346
+ if (!stageEnv.srcCtx) stageEnv.srcCtx = from.getContext("2d", ctxOpts);
1432
1347
  this.debug("Get tile pixel data");
1433
1348
  return Object.assign({}, extractTo, {
1434
1349
  kind: "array",
@@ -1437,7 +1352,7 @@ var Pica = class {
1437
1352
  }
1438
1353
  this.debug("Draw tile imageBitmap/image to temporary canvas");
1439
1354
  const tmpCanvas = this.createCanvas(tile.width, tile.height, { preferOffscreen: true });
1440
- const tmpCtx = tmpCanvas.getContext("2d");
1355
+ const tmpCtx = tmpCanvas.getContext("2d", ctxOpts);
1441
1356
  tmpCtx.globalCompositeOperation = "copy";
1442
1357
  tmpCtx.drawImage(stageEnv.srcImageBitmap || from, tile.x, tile.y, tile.width, tile.height, 0, 0, tile.width, tile.height);
1443
1358
  this.debug("Get tile pixel data");
@@ -1494,7 +1409,7 @@ var Pica = class {
1494
1409
  return _this3.__landTileData(tile, result, stageEnv);
1495
1410
  }));
1496
1411
  yield Promise.resolve();
1497
- stageEnv.toCtx = to.getContext("2d");
1412
+ stageEnv.toCtx = to.getContext("2d", ctxOpts);
1498
1413
  if (isCanvas(from)) {} else if (isImageBitmap(from)) {
1499
1414
  stageEnv.srcImageBitmap = from;
1500
1415
  stageEnv.isImageBitmapReused = true;
@@ -1574,7 +1489,7 @@ var Pica = class {
1574
1489
  var _this5 = this;
1575
1490
  return _asyncToGenerator(function* () {
1576
1491
  var _utils$filter_to_cib_;
1577
- let toCtx = to.getContext("2d");
1492
+ let toCtx = to.getContext("2d", ctxOpts);
1578
1493
  _this5.debug("Resize via createImageBitmap()");
1579
1494
  const imageBitmap = yield createImageBitmap(from, {
1580
1495
  resizeWidth: resizeParams.toWidth,
@@ -1591,7 +1506,7 @@ var Pica = class {
1591
1506
  }
1592
1507
  _this5.debug("Unsharp result");
1593
1508
  let tmpCanvas = _this5.createCanvas(resizeParams.toWidth, resizeParams.toHeight);
1594
- let tmpCtx = tmpCanvas.getContext("2d");
1509
+ let tmpCtx = tmpCanvas.getContext("2d", ctxOpts);
1595
1510
  tmpCtx.drawImage(imageBitmap, 0, 0);
1596
1511
  imageBitmap.close();
1597
1512
  let iData = tmpCtx.getImageData(0, 0, resizeParams.toWidth, resizeParams.toHeight);
@@ -1642,7 +1557,7 @@ var Pica = class {
1642
1557
  if (ctx.canceled) return ctx.cancelToken;
1643
1558
  if (_this6.capabilities.bug_image_bitmap_orientation_region && (isImage(from) || isImageBitmap(from))) {
1644
1559
  const tmpCanvas = _this6.createCanvas(resizeParams.width, resizeParams.height);
1645
- tmpCanvas.getContext("2d").drawImage(from, 0, 0);
1560
+ tmpCanvas.getContext("2d", ctxOpts).drawImage(from, 0, 0);
1646
1561
  from = tmpCanvas;
1647
1562
  }
1648
1563
  if (_this6.resize_features.cib) {