@oh-my-pi/pi-coding-agent 5.6.77 → 5.7.68

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.json +8 -8
  3. package/src/migrations.ts +1 -34
  4. package/src/utils/image-convert.ts +1 -1
  5. package/src/utils/image-resize.ts +2 -2
  6. package/src/vendor/photon/LICENSE.md +201 -0
  7. package/src/vendor/photon/README.md +158 -0
  8. package/src/vendor/photon/index.d.ts +3013 -0
  9. package/src/vendor/photon/index.js +4461 -0
  10. package/src/vendor/photon/photon_rs_bg.wasm +0 -0
  11. package/src/vendor/photon/photon_rs_bg.wasm.b64.js +1 -0
  12. package/src/vendor/photon/photon_rs_bg.wasm.d.ts +193 -0
  13. package/src/core/python-executor-display.test.ts +0 -42
  14. package/src/core/python-executor-lifecycle.test.ts +0 -99
  15. package/src/core/python-executor-mapping.test.ts +0 -41
  16. package/src/core/python-executor-per-call.test.ts +0 -49
  17. package/src/core/python-executor-session.test.ts +0 -103
  18. package/src/core/python-executor-streaming.test.ts +0 -77
  19. package/src/core/python-executor-timeout.test.ts +0 -35
  20. package/src/core/python-executor.lifecycle.test.ts +0 -139
  21. package/src/core/python-executor.result.test.ts +0 -49
  22. package/src/core/python-executor.test.ts +0 -180
  23. package/src/core/python-kernel-display.test.ts +0 -54
  24. package/src/core/python-kernel-env.test.ts +0 -138
  25. package/src/core/python-kernel-session.test.ts +0 -87
  26. package/src/core/python-kernel-ws.test.ts +0 -104
  27. package/src/core/python-kernel.lifecycle.test.ts +0 -249
  28. package/src/core/python-kernel.test.ts +0 -461
  29. package/src/core/python-modules.test.ts +0 -102
  30. package/src/core/python-prelude.test.ts +0 -140
  31. package/src/core/settings-manager-python.test.ts +0 -23
  32. package/src/core/streaming-output.test.ts +0 -26
  33. package/src/core/system-prompt.python.test.ts +0 -17
  34. package/src/core/tools/index.test.ts +0 -212
  35. package/src/core/tools/python-execution.test.ts +0 -68
  36. package/src/core/tools/python-fallback.test.ts +0 -72
  37. package/src/core/tools/python-renderer.test.ts +0 -36
  38. package/src/core/tools/python-tool-mode.test.ts +0 -43
  39. package/src/core/tools/python.test.ts +0 -121
  40. package/src/core/tools/schema-validation.test.ts +0 -530
  41. package/src/core/tools/web-scrapers/academic.test.ts +0 -239
  42. package/src/core/tools/web-scrapers/business.test.ts +0 -82
  43. package/src/core/tools/web-scrapers/dev-platforms.test.ts +0 -254
  44. package/src/core/tools/web-scrapers/documentation.test.ts +0 -85
  45. package/src/core/tools/web-scrapers/finance-media.test.ts +0 -144
  46. package/src/core/tools/web-scrapers/git-hosting.test.ts +0 -272
  47. package/src/core/tools/web-scrapers/media.test.ts +0 -138
  48. package/src/core/tools/web-scrapers/package-managers-2.test.ts +0 -199
  49. package/src/core/tools/web-scrapers/package-managers.test.ts +0 -171
  50. package/src/core/tools/web-scrapers/package-registries.test.ts +0 -259
  51. package/src/core/tools/web-scrapers/research.test.ts +0 -107
  52. package/src/core/tools/web-scrapers/security.test.ts +0 -103
  53. package/src/core/tools/web-scrapers/social-extended.test.ts +0 -192
  54. package/src/core/tools/web-scrapers/social.test.ts +0 -259
  55. package/src/core/tools/web-scrapers/stackexchange.test.ts +0 -120
  56. package/src/core/tools/web-scrapers/standards.test.ts +0 -122
  57. package/src/core/tools/web-scrapers/wikipedia.test.ts +0 -73
  58. package/src/core/tools/web-scrapers/youtube.test.ts +0 -198
  59. package/src/discovery/helpers.test.ts +0 -131
@@ -0,0 +1,4461 @@
1
+ /* @ts-self-types="./photon_rs.d.ts" */
2
+ import wasmBase64 from "./photon_rs_bg.wasm.b64.js";
3
+
4
+ /**
5
+ * Provides the image's height, width, and contains the image's raw pixels.
6
+ * For use when communicating between JS and WASM, and also natively.
7
+ */
8
+ export class PhotonImage {
9
+ static __wrap(ptr) {
10
+ ptr = ptr >>> 0;
11
+ const obj = Object.create(PhotonImage.prototype);
12
+ obj.__wbg_ptr = ptr;
13
+ PhotonImageFinalization.register(obj, obj.__wbg_ptr, obj);
14
+ return obj;
15
+ }
16
+ __destroy_into_raw() {
17
+ const ptr = this.__wbg_ptr;
18
+ this.__wbg_ptr = 0;
19
+ PhotonImageFinalization.unregister(this);
20
+ return ptr;
21
+ }
22
+ free() {
23
+ const ptr = this.__destroy_into_raw();
24
+ wasm.__wbg_photonimage_free(ptr, 0);
25
+ }
26
+ /**
27
+ * Convert the PhotonImage to base64.
28
+ * @returns {string}
29
+ */
30
+ get_base64() {
31
+ let deferred1_0;
32
+ let deferred1_1;
33
+ try {
34
+ const ret = wasm.photonimage_get_base64(this.__wbg_ptr);
35
+ deferred1_0 = ret[0];
36
+ deferred1_1 = ret[1];
37
+ return getStringFromWasm0(ret[0], ret[1]);
38
+ } finally {
39
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
40
+ }
41
+ }
42
+ /**
43
+ * Convert the PhotonImage to raw bytes. Returns PNG.
44
+ * @returns {Uint8Array}
45
+ */
46
+ get_bytes() {
47
+ const ret = wasm.photonimage_get_bytes(this.__wbg_ptr);
48
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
49
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
50
+ return v1;
51
+ }
52
+ /**
53
+ * Convert the PhotonImage to raw bytes. Returns a JPEG.
54
+ * @param {number} quality
55
+ * @returns {Uint8Array}
56
+ */
57
+ get_bytes_jpeg(quality) {
58
+ const ret = wasm.photonimage_get_bytes_jpeg(this.__wbg_ptr, quality);
59
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
60
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
61
+ return v1;
62
+ }
63
+ /**
64
+ * Convert the PhotonImage to raw bytes. Returns a WEBP.
65
+ * @returns {Uint8Array}
66
+ */
67
+ get_bytes_webp() {
68
+ const ret = wasm.photonimage_get_bytes_webp(this.__wbg_ptr);
69
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
70
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
71
+ return v1;
72
+ }
73
+ /**
74
+ * Calculates estimated filesize and returns number of bytes
75
+ * @returns {bigint}
76
+ */
77
+ get_estimated_filesize() {
78
+ const ret = wasm.photonimage_get_estimated_filesize(this.__wbg_ptr);
79
+ return BigInt.asUintN(64, ret);
80
+ }
81
+ /**
82
+ * Get the height of the PhotonImage.
83
+ * @returns {number}
84
+ */
85
+ get_height() {
86
+ const ret = wasm.photonimage_get_height(this.__wbg_ptr);
87
+ return ret >>> 0;
88
+ }
89
+ /**
90
+ * Convert the PhotonImage's raw pixels to JS-compatible ImageData.
91
+ * @returns {ImageData}
92
+ */
93
+ get_image_data() {
94
+ const ret = wasm.photonimage_get_image_data(this.__wbg_ptr);
95
+ return ret;
96
+ }
97
+ /**
98
+ * Get the PhotonImage's pixels as a Vec of u8s.
99
+ * @returns {Uint8Array}
100
+ */
101
+ get_raw_pixels() {
102
+ const ret = wasm.photonimage_get_raw_pixels(this.__wbg_ptr);
103
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
104
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
105
+ return v1;
106
+ }
107
+ /**
108
+ * Get the width of the PhotonImage.
109
+ * @returns {number}
110
+ */
111
+ get_width() {
112
+ const ret = wasm.photonimage_get_width(this.__wbg_ptr);
113
+ return ret >>> 0;
114
+ }
115
+ /**
116
+ * Create a new PhotonImage from a Vec of u8s, which represent raw pixels.
117
+ * @param {Uint8Array} raw_pixels
118
+ * @param {number} width
119
+ * @param {number} height
120
+ */
121
+ constructor(raw_pixels, width, height) {
122
+ const ptr0 = passArray8ToWasm0(raw_pixels, wasm.__wbindgen_malloc);
123
+ const len0 = WASM_VECTOR_LEN;
124
+ const ret = wasm.photonimage_new(ptr0, len0, width, height);
125
+ this.__wbg_ptr = ret >>> 0;
126
+ PhotonImageFinalization.register(this, this.__wbg_ptr, this);
127
+ return this;
128
+ }
129
+ /**
130
+ * Create a new PhotonImage from a base64 string.
131
+ * @param {string} base64
132
+ * @returns {PhotonImage}
133
+ */
134
+ static new_from_base64(base64) {
135
+ const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136
+ const len0 = WASM_VECTOR_LEN;
137
+ const ret = wasm.base64_to_image(ptr0, len0);
138
+ return PhotonImage.__wrap(ret);
139
+ }
140
+ /**
141
+ * Create a new PhotonImage from a Blob/File.
142
+ * @param {Blob} blob
143
+ * @returns {PhotonImage}
144
+ */
145
+ static new_from_blob(blob) {
146
+ const ret = wasm.photonimage_new_from_blob(blob);
147
+ return PhotonImage.__wrap(ret);
148
+ }
149
+ /**
150
+ * Create a new PhotonImage from a byteslice.
151
+ * @param {Uint8Array} vec
152
+ * @returns {PhotonImage}
153
+ */
154
+ static new_from_byteslice(vec) {
155
+ const ptr0 = passArray8ToWasm0(vec, wasm.__wbindgen_malloc);
156
+ const len0 = WASM_VECTOR_LEN;
157
+ const ret = wasm.photonimage_new_from_byteslice(ptr0, len0);
158
+ return PhotonImage.__wrap(ret);
159
+ }
160
+ /**
161
+ * Create a new PhotonImage from a HTMLImageElement
162
+ * @param {HTMLImageElement} image
163
+ * @returns {PhotonImage}
164
+ */
165
+ static new_from_image(image) {
166
+ const ret = wasm.photonimage_new_from_image(image);
167
+ return PhotonImage.__wrap(ret);
168
+ }
169
+ /**
170
+ * Convert ImageData to raw pixels, and update the PhotonImage's raw pixels to this.
171
+ * @param {ImageData} img_data
172
+ */
173
+ set_imgdata(img_data) {
174
+ wasm.photonimage_set_imgdata(this.__wbg_ptr, img_data);
175
+ }
176
+ }
177
+ if (Symbol.dispose) PhotonImage.prototype[Symbol.dispose] = PhotonImage.prototype.free;
178
+
179
+ /**
180
+ * RGB color type.
181
+ */
182
+ export class Rgb {
183
+ __destroy_into_raw() {
184
+ const ptr = this.__wbg_ptr;
185
+ this.__wbg_ptr = 0;
186
+ RgbFinalization.unregister(this);
187
+ return ptr;
188
+ }
189
+ free() {
190
+ const ptr = this.__destroy_into_raw();
191
+ wasm.__wbg_rgb_free(ptr, 0);
192
+ }
193
+ /**
194
+ * Get the Blue value.
195
+ * @returns {number}
196
+ */
197
+ get_blue() {
198
+ const ret = wasm.rgb_get_blue(this.__wbg_ptr);
199
+ return ret;
200
+ }
201
+ /**
202
+ * Get the Green value.
203
+ * @returns {number}
204
+ */
205
+ get_green() {
206
+ const ret = wasm.rgb_get_green(this.__wbg_ptr);
207
+ return ret;
208
+ }
209
+ /**
210
+ * Get the Red value.
211
+ * @returns {number}
212
+ */
213
+ get_red() {
214
+ const ret = wasm.rgb_get_red(this.__wbg_ptr);
215
+ return ret;
216
+ }
217
+ /**
218
+ * Create a new RGB struct.
219
+ * @param {number} r
220
+ * @param {number} g
221
+ * @param {number} b
222
+ */
223
+ constructor(r, g, b) {
224
+ const ret = wasm.rgb_new(r, g, b);
225
+ this.__wbg_ptr = ret >>> 0;
226
+ RgbFinalization.register(this, this.__wbg_ptr, this);
227
+ return this;
228
+ }
229
+ /**
230
+ * Set the Blue value.
231
+ * @param {number} b
232
+ */
233
+ set_blue(b) {
234
+ wasm.rgb_set_blue(this.__wbg_ptr, b);
235
+ }
236
+ /**
237
+ * Get the Green value.
238
+ * @param {number} g
239
+ */
240
+ set_green(g) {
241
+ wasm.rgb_set_green(this.__wbg_ptr, g);
242
+ }
243
+ /**
244
+ * Set the Red value.
245
+ * @param {number} r
246
+ */
247
+ set_red(r) {
248
+ wasm.rgb_set_red(this.__wbg_ptr, r);
249
+ }
250
+ }
251
+ if (Symbol.dispose) Rgb.prototype[Symbol.dispose] = Rgb.prototype.free;
252
+
253
+ /**
254
+ * RGBA color type.
255
+ */
256
+ export class Rgba {
257
+ __destroy_into_raw() {
258
+ const ptr = this.__wbg_ptr;
259
+ this.__wbg_ptr = 0;
260
+ RgbaFinalization.unregister(this);
261
+ return ptr;
262
+ }
263
+ free() {
264
+ const ptr = this.__destroy_into_raw();
265
+ wasm.__wbg_rgba_free(ptr, 0);
266
+ }
267
+ /**
268
+ * Get the alpha value for this color.
269
+ * @returns {number}
270
+ */
271
+ get_alpha() {
272
+ const ret = wasm.rgba_get_alpha(this.__wbg_ptr);
273
+ return ret;
274
+ }
275
+ /**
276
+ * Get the Blue value.
277
+ * @returns {number}
278
+ */
279
+ get_blue() {
280
+ const ret = wasm.rgb_get_blue(this.__wbg_ptr);
281
+ return ret;
282
+ }
283
+ /**
284
+ * Get the Green value.
285
+ * @returns {number}
286
+ */
287
+ get_green() {
288
+ const ret = wasm.rgb_get_green(this.__wbg_ptr);
289
+ return ret;
290
+ }
291
+ /**
292
+ * Get the Red value.
293
+ * @returns {number}
294
+ */
295
+ get_red() {
296
+ const ret = wasm.rgb_get_red(this.__wbg_ptr);
297
+ return ret;
298
+ }
299
+ /**
300
+ * Create a new RGBA struct.
301
+ * @param {number} r
302
+ * @param {number} g
303
+ * @param {number} b
304
+ * @param {number} a
305
+ */
306
+ constructor(r, g, b, a) {
307
+ const ret = wasm.rgba_new(r, g, b, a);
308
+ this.__wbg_ptr = ret >>> 0;
309
+ RgbaFinalization.register(this, this.__wbg_ptr, this);
310
+ return this;
311
+ }
312
+ /**
313
+ * Set the alpha value.
314
+ * @param {number} a
315
+ */
316
+ set_alpha(a) {
317
+ wasm.rgba_set_alpha(this.__wbg_ptr, a);
318
+ }
319
+ /**
320
+ * Set the Blue value.
321
+ * @param {number} b
322
+ */
323
+ set_blue(b) {
324
+ wasm.rgb_set_blue(this.__wbg_ptr, b);
325
+ }
326
+ /**
327
+ * Get the Green value.
328
+ * @param {number} g
329
+ */
330
+ set_green(g) {
331
+ wasm.rgb_set_green(this.__wbg_ptr, g);
332
+ }
333
+ /**
334
+ * Set the Red value.
335
+ * @param {number} r
336
+ */
337
+ set_red(r) {
338
+ wasm.rgb_set_red(this.__wbg_ptr, r);
339
+ }
340
+ }
341
+ if (Symbol.dispose) Rgba.prototype[Symbol.dispose] = Rgba.prototype.free;
342
+
343
+ /**
344
+ * @enum {1 | 2 | 3 | 4 | 5}
345
+ */
346
+ export const SamplingFilter = Object.freeze({
347
+ Nearest: 1, "1": "Nearest",
348
+ Triangle: 2, "2": "Triangle",
349
+ CatmullRom: 3, "3": "CatmullRom",
350
+ Gaussian: 4, "4": "Gaussian",
351
+ Lanczos3: 5, "5": "Lanczos3",
352
+ });
353
+
354
+ /**
355
+ * Add randomized noise to an image.
356
+ * This function adds a Gaussian Noise Sample to each pixel through incrementing each channel by a randomized offset.
357
+ * This randomized offset is generated by creating a randomized thread pool.
358
+ * **[WASM SUPPORT IS AVAILABLE]**: Randomized thread pools cannot be created with WASM, but
359
+ * a workaround using js_sys::Math::random works now.
360
+ * # Arguments
361
+ * * `img` - A PhotonImage.
362
+ *
363
+ * # Example
364
+ *
365
+ * ```no_run
366
+ * // For example:
367
+ * use photon_rs::native::open_image;
368
+ * use photon_rs::noise::add_noise_rand;
369
+ * use photon_rs::PhotonImage;
370
+ *
371
+ * let mut img = open_image("img.jpg").expect("File should open");
372
+ * add_noise_rand(&mut img);
373
+ * ```
374
+ * @param {PhotonImage} photon_image
375
+ */
376
+ export function add_noise_rand(photon_image) {
377
+ _assertClass(photon_image, PhotonImage);
378
+ wasm.add_noise_rand(photon_image.__wbg_ptr);
379
+ }
380
+
381
+ /**
382
+ * Adjust the brightness of an image by a factor.
383
+ *
384
+ * # Arguments
385
+ * * `img` - A PhotonImage that contains a view into the image.
386
+ * * `brightness` - A u8 to add or subtract to the brightness. To increase
387
+ * the brightness, pass a positive number (up to 255). To decrease the brightness,
388
+ * pass a negative number instead.
389
+ * # Example
390
+ *
391
+ * ```no_run
392
+ * use photon_rs::effects::adjust_brightness;
393
+ * use photon_rs::native::open_image;
394
+ *
395
+ * let mut img = open_image("img.jpg").expect("File should open");
396
+ * adjust_brightness(&mut img, 10_i16);
397
+ * ```
398
+ * @param {PhotonImage} photon_image
399
+ * @param {number} brightness
400
+ */
401
+ export function adjust_brightness(photon_image, brightness) {
402
+ _assertClass(photon_image, PhotonImage);
403
+ wasm.adjust_brightness(photon_image.__wbg_ptr, brightness);
404
+ }
405
+
406
+ /**
407
+ * Adjust the contrast of an image by a factor.
408
+ *
409
+ * # Arguments
410
+ * * `photon_image` - A PhotonImage that contains a view into the image.
411
+ * * `contrast` - An f32 factor used to adjust contrast. Between [-255.0, 255.0]. The algorithm will
412
+ * clamp results if passed factor is out of range.
413
+ * # Example
414
+ *
415
+ * ```no_run
416
+ * use photon_rs::effects::adjust_contrast;
417
+ * use photon_rs::native::open_image;
418
+ *
419
+ * let mut img = open_image("img.jpg").expect("File should open");
420
+ * adjust_contrast(&mut img, 30_f32);
421
+ * ```
422
+ * @param {PhotonImage} photon_image
423
+ * @param {number} contrast
424
+ */
425
+ export function adjust_contrast(photon_image, contrast) {
426
+ _assertClass(photon_image, PhotonImage);
427
+ wasm.adjust_contrast(photon_image.__wbg_ptr, contrast);
428
+ }
429
+
430
+ /**
431
+ * Increment or decrement every pixel's Blue channel by a constant.
432
+ *
433
+ * # Arguments
434
+ * * `img` - A PhotonImage.
435
+ * * `amt` - The amount to increment or decrement the channel's value by for that pixel.
436
+ *
437
+ * # Example
438
+ *
439
+ * ```no_run
440
+ * // For example, to increase the Blue channel for all pixels by 10:
441
+ * use photon_rs::channels::alter_blue_channel;
442
+ * use photon_rs::native::open_image;
443
+ *
444
+ * let mut img = open_image("img.jpg").expect("File should open");
445
+ * alter_blue_channel(&mut img, 10_i16);
446
+ * ```
447
+ * @param {PhotonImage} img
448
+ * @param {number} amt
449
+ */
450
+ export function alter_blue_channel(img, amt) {
451
+ _assertClass(img, PhotonImage);
452
+ wasm.alter_blue_channel(img.__wbg_ptr, amt);
453
+ }
454
+
455
+ /**
456
+ * Alter a select channel by incrementing or decrementing its value by a constant.
457
+ *
458
+ * # Arguments
459
+ * * `img` - A PhotonImage.
460
+ * * `channel` - The channel you wish to alter, it should be either 0, 1 or 2,
461
+ * representing R, G, or B respectively. (O=Red, 1=Green, 2=Blue)
462
+ * * `amount` - The amount to increment/decrement the channel's value by for that pixel.
463
+ * A positive value will increment/decrement the channel's value, a negative value will decrement the channel's value.
464
+ *
465
+ * ## Example
466
+ *
467
+ * ```no_run
468
+ * // For example, to increase the Red channel for all pixels by 10:
469
+ * use photon_rs::channels::alter_channel;
470
+ * use photon_rs::native::{open_image};
471
+ *
472
+ * let mut img = open_image("img.jpg").expect("File should open");
473
+ * alter_channel(&mut img, 0_usize, 10_i16);
474
+ * ```
475
+ *
476
+ * Adds a constant to a select R, G, or B channel's value.
477
+ *
478
+ * ### Decrease a channel's value
479
+ * // For example, to decrease the Green channel for all pixels by 20:
480
+ * ```no_run
481
+ * use photon_rs::channels::alter_channel;
482
+ * use photon_rs::native::open_image;
483
+ *
484
+ * let mut img = open_image("img.jpg").expect("File should open");
485
+ * alter_channel(&mut img, 1_usize, -20_i16);
486
+ * ```
487
+ * **Note**: Note the use of a minus symbol when decreasing the channel.
488
+ * @param {PhotonImage} img
489
+ * @param {number} channel
490
+ * @param {number} amt
491
+ */
492
+ export function alter_channel(img, channel, amt) {
493
+ _assertClass(img, PhotonImage);
494
+ wasm.alter_channel(img.__wbg_ptr, channel, amt);
495
+ }
496
+
497
+ /**
498
+ * Increment all 3 channels' values by adding an amt to each channel per pixel.
499
+ *
500
+ * # Arguments
501
+ * * `img` - A PhotonImage.
502
+ * * `r_amt` - The amount to increment/decrement the Red channel by.
503
+ * * `g_amt` - The amount to increment/decrement the Green channel by.
504
+ * * `b_amt` - The amount to increment/decrement the Blue channel by.
505
+ *
506
+ * # Example
507
+ *
508
+ * ```no_run
509
+ * // For example, to increase the values of the Red channel by 10, the Green channel by 20,
510
+ * // and the Blue channel by 50:
511
+ * use photon_rs::channels::alter_channels;
512
+ * use photon_rs::native::open_image;
513
+ *
514
+ * let mut img = open_image("img.jpg").expect("File should open");
515
+ * alter_channels(&mut img, 10_i16, 20_i16, 50_i16);
516
+ * ```
517
+ * @param {PhotonImage} img
518
+ * @param {number} r_amt
519
+ * @param {number} g_amt
520
+ * @param {number} b_amt
521
+ */
522
+ export function alter_channels(img, r_amt, g_amt, b_amt) {
523
+ _assertClass(img, PhotonImage);
524
+ wasm.alter_channels(img.__wbg_ptr, r_amt, g_amt, b_amt);
525
+ }
526
+
527
+ /**
528
+ * Increment or decrement every pixel's Green channel by a constant.
529
+ *
530
+ * # Arguments
531
+ * * `img` - A PhotonImage.
532
+ * * `amt` - The amount to increment/decrement the channel's value by for that pixel.
533
+ *
534
+ * # Example
535
+ *
536
+ * ```no_run
537
+ * // For example, to increase the Green channel for all pixels by 20:
538
+ * use photon_rs::channels::alter_green_channel;
539
+ * use photon_rs::native::open_image;
540
+ *
541
+ * let mut img = open_image("img.jpg").expect("File should open");
542
+ * alter_green_channel(&mut img, 20_i16);
543
+ * ```
544
+ * @param {PhotonImage} img
545
+ * @param {number} amt
546
+ */
547
+ export function alter_green_channel(img, amt) {
548
+ _assertClass(img, PhotonImage);
549
+ wasm.alter_green_channel(img.__wbg_ptr, amt);
550
+ }
551
+
552
+ /**
553
+ * Increment or decrement every pixel's Red channel by a constant.
554
+ *
555
+ * # Arguments
556
+ * * `img` - A PhotonImage. See the PhotonImage struct for details.
557
+ * * `amt` - The amount to increment or decrement the channel's value by for that pixel.
558
+ *
559
+ * # Example
560
+ *
561
+ * ```no_run
562
+ * // For example, to increase the Red channel for all pixels by 10:
563
+ * use photon_rs::channels::alter_red_channel;
564
+ * use photon_rs::native::open_image;
565
+ *
566
+ * let mut img = open_image("img.jpg").expect("File should open");
567
+ * alter_red_channel(&mut img, 10_i16);
568
+ * ```
569
+ * @param {PhotonImage} photon_image
570
+ * @param {number} amt
571
+ */
572
+ export function alter_red_channel(photon_image, amt) {
573
+ _assertClass(photon_image, PhotonImage);
574
+ wasm.alter_red_channel(photon_image.__wbg_ptr, amt);
575
+ }
576
+
577
+ /**
578
+ * Increment/decrement two channels' values simultaneously by adding an amt to each channel per pixel.
579
+ *
580
+ * # Arguments
581
+ * * `img` - A PhotonImage.
582
+ * * `channel1` - A usize from 0 to 2 that represents either the R, G or B channels.
583
+ * * `amt1` - The amount to increment/decrement the channel's value by for that pixel.
584
+ * * `channel2` -A usize from 0 to 2 that represents either the R, G or B channels.
585
+ * * `amt2` - The amount to increment/decrement the channel's value by for that pixel.
586
+ *
587
+ * # Example
588
+ *
589
+ * ```no_run
590
+ * // For example, to increase the values of the Red and Blue channels per pixel:
591
+ * use photon_rs::channels::alter_two_channels;
592
+ * use photon_rs::native::open_image;
593
+ *
594
+ * let mut img = open_image("img.jpg").expect("File should open");
595
+ * alter_two_channels(&mut img, 0_usize, 10_i16, 2_usize, 20_i16);
596
+ * ```
597
+ * @param {PhotonImage} img
598
+ * @param {number} channel1
599
+ * @param {number} amt1
600
+ * @param {number} channel2
601
+ * @param {number} amt2
602
+ */
603
+ export function alter_two_channels(img, channel1, amt1, channel2, amt2) {
604
+ _assertClass(img, PhotonImage);
605
+ wasm.alter_two_channels(img.__wbg_ptr, channel1, amt1, channel2, amt2);
606
+ }
607
+
608
+ /**
609
+ * Apply a gradient to an image.
610
+ * @param {PhotonImage} image
611
+ */
612
+ export function apply_gradient(image) {
613
+ _assertClass(image, PhotonImage);
614
+ wasm.apply_gradient(image.__wbg_ptr);
615
+ }
616
+
617
+ /**
618
+ * Convert an image to grayscale by setting a pixel's 3 RGB values to the Blue channel's value.
619
+ *
620
+ * # Arguments
621
+ * * `photon_image` - A PhotonImage.
622
+ *
623
+ * # Example
624
+ *
625
+ * ```no_run
626
+ * use photon_rs::monochrome::b_grayscale;
627
+ * use photon_rs::native::open_image;
628
+ *
629
+ * let mut img = open_image("img.jpg").expect("File should open");
630
+ * b_grayscale(&mut img);
631
+ * ```
632
+ * @param {PhotonImage} photon_image
633
+ */
634
+ export function b_grayscale(photon_image) {
635
+ _assertClass(photon_image, PhotonImage);
636
+ wasm.b_grayscale(photon_image.__wbg_ptr);
637
+ }
638
+
639
+ /**
640
+ * Convert a base64 string to a PhotonImage.
641
+ * @param {string} base64
642
+ * @returns {PhotonImage}
643
+ */
644
+ export function base64_to_image(base64) {
645
+ const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
646
+ const len0 = WASM_VECTOR_LEN;
647
+ const ret = wasm.base64_to_image(ptr0, len0);
648
+ return PhotonImage.__wrap(ret);
649
+ }
650
+
651
+ /**
652
+ * Convert a base64 string to a Vec of u8s.
653
+ * @param {string} base64
654
+ * @returns {Uint8Array}
655
+ */
656
+ export function base64_to_vec(base64) {
657
+ const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
658
+ const len0 = WASM_VECTOR_LEN;
659
+ const ret = wasm.base64_to_vec(ptr0, len0);
660
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
661
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
662
+ return v2;
663
+ }
664
+
665
+ /**
666
+ * Blend two images together.
667
+ *
668
+ * The `blend_mode` (3rd param) determines which blending mode to use; change this for varying effects.
669
+ * The blend modes available include: `overlay`, `over`, `atop`, `xor`, `plus`, `multiply`, `burn`,
670
+ * `difference`, `soft_light`, `screen`, `hard_light`, `dodge`, `exclusion`, `lighten`, `darken` (more to come)
671
+ * NOTE: The first image must be smaller than the second image passed as params.
672
+ * If the first image were larger than the second, then there would be overflowing pixels which would have no corresponding pixels
673
+ * in the second image.
674
+ * # Arguments
675
+ * * `img` - A DynamicImage that contains a view into the image.
676
+ * * `img2` - The 2nd DynamicImage to be blended with the first.
677
+ * * `blend_mode` - The blending mode to use. See above for complete list of blend modes available.
678
+ * # Example
679
+ *
680
+ * ```no_run
681
+ * // For example, to blend two images with the `multiply` blend mode:
682
+ * use photon_rs::multiple::blend;
683
+ * use photon_rs::native::open_image;
684
+ *
685
+ * let mut img = open_image("img.jpg").expect("File should open");
686
+ * let img2 = open_image("img2.jpg").expect("File should open");
687
+ * blend(&mut img, &img2, "multiply");
688
+ * ```
689
+ * @param {PhotonImage} photon_image
690
+ * @param {PhotonImage} photon_image2
691
+ * @param {string} blend_mode
692
+ */
693
+ export function blend(photon_image, photon_image2, blend_mode) {
694
+ _assertClass(photon_image, PhotonImage);
695
+ _assertClass(photon_image2, PhotonImage);
696
+ const ptr0 = passStringToWasm0(blend_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
697
+ const len0 = WASM_VECTOR_LEN;
698
+ wasm.blend(photon_image.__wbg_ptr, photon_image2.__wbg_ptr, ptr0, len0);
699
+ }
700
+
701
+ /**
702
+ * Apply a box blur effect.
703
+ *
704
+ * # Arguments
705
+ * * `img` - A PhotonImage.
706
+ *
707
+ * # Example
708
+ *
709
+ * ```no_run
710
+ * // For example, to apply a box blur effect:
711
+ * use photon_rs::conv::box_blur;
712
+ * use photon_rs::native::open_image;
713
+ *
714
+ * let mut img = open_image("img.jpg").expect("File should open");
715
+ * box_blur(&mut img);
716
+ * ```
717
+ * @param {PhotonImage} photon_image
718
+ */
719
+ export function box_blur(photon_image) {
720
+ _assertClass(photon_image, PhotonImage);
721
+ wasm.box_blur(photon_image.__wbg_ptr);
722
+ }
723
+
724
+ /**
725
+ * Increased contrast filter effect.
726
+ *
727
+ * # Arguments
728
+ * * `img` - A PhotonImage.
729
+ * # Example
730
+ *
731
+ * ```no_run
732
+ * use photon_rs::filters::cali;
733
+ * use photon_rs::native::open_image;
734
+ *
735
+ * let mut img = open_image("img.jpg").expect("File should open");
736
+ * cali(&mut img);
737
+ * ```
738
+ * @param {PhotonImage} img
739
+ */
740
+ export function cali(img) {
741
+ _assertClass(img, PhotonImage);
742
+ wasm.cali(img.__wbg_ptr);
743
+ }
744
+
745
+ /**
746
+ * Horizontal strips. Divide an image into a series of equal-width strips, for an artistic effect. Sepcify a color as well.
747
+ *
748
+ * # Arguments
749
+ * * `img` - A PhotonImage that contains a view into the image.
750
+ * * `num_strips` - The numbder of strips
751
+ * * `color` - Color of strips.
752
+ * # Example
753
+ *
754
+ * ```no_run
755
+ * // For example, to draw blue horizontal strips on a `PhotonImage`:
756
+ * use photon_rs::effects::color_horizontal_strips;
757
+ * use photon_rs::native::open_image;
758
+ * use photon_rs::Rgb;
759
+ *
760
+ * let color = Rgb::new(255u8, 0u8, 0u8);
761
+ * let mut img = open_image("img.jpg").expect("File should open");
762
+ * color_horizontal_strips(&mut img, 8u8, color);
763
+ * ```
764
+ * @param {PhotonImage} photon_image
765
+ * @param {number} num_strips
766
+ * @param {Rgb} color
767
+ */
768
+ export function color_horizontal_strips(photon_image, num_strips, color) {
769
+ _assertClass(photon_image, PhotonImage);
770
+ _assertClass(color, Rgb);
771
+ var ptr0 = color.__destroy_into_raw();
772
+ wasm.color_horizontal_strips(photon_image.__wbg_ptr, num_strips, ptr0);
773
+ }
774
+
775
+ /**
776
+ * Vertical strips. Divide an image into a series of equal-width strips, for an artistic effect. Sepcify a color as well.
777
+ *
778
+ * # Arguments
779
+ * * `img` - A PhotonImage that contains a view into the image.
780
+ * * `num_strips` - The numbder of strips
781
+ * * `color` - Color of strips.
782
+ * # Example
783
+ *
784
+ * ```no_run
785
+ * // For example, to draw red vertical strips on a `PhotonImage`:
786
+ * use photon_rs::effects::color_vertical_strips;
787
+ * use photon_rs::native::open_image;
788
+ * use photon_rs::Rgb;
789
+ *
790
+ * let color = Rgb::new(255u8, 0u8, 0u8);
791
+ * let mut img = open_image("img.jpg").expect("File should open");
792
+ * color_vertical_strips(&mut img, 8u8, color);
793
+ * ```
794
+ * @param {PhotonImage} photon_image
795
+ * @param {number} num_strips
796
+ * @param {Rgb} color
797
+ */
798
+ export function color_vertical_strips(photon_image, num_strips, color) {
799
+ _assertClass(photon_image, PhotonImage);
800
+ _assertClass(color, Rgb);
801
+ var ptr0 = color.__destroy_into_raw();
802
+ wasm.color_vertical_strips(photon_image.__wbg_ptr, num_strips, ptr0);
803
+ }
804
+
805
+ /**
806
+ * Colorizes the green channels of the image.
807
+ *
808
+ * # Arguments
809
+ * * `img` - A PhotonImage that contains a view into the image.
810
+ * # Example
811
+ *
812
+ * ```no_run
813
+ * // For example, to colorize an image of type `PhotonImage`:
814
+ * use photon_rs::effects::colorize;
815
+ * use photon_rs::native::open_image;
816
+ *
817
+ * let mut img = open_image("img.jpg").expect("File should open");
818
+ * colorize(&mut img);
819
+ * ```
820
+ * @param {PhotonImage} photon_image
821
+ */
822
+ export function colorize(photon_image) {
823
+ _assertClass(photon_image, PhotonImage);
824
+ wasm.colorize(photon_image.__wbg_ptr);
825
+ }
826
+
827
+ /**
828
+ * @param {number} width
829
+ * @param {number} height
830
+ * @returns {PhotonImage}
831
+ */
832
+ export function create_gradient(width, height) {
833
+ const ret = wasm.create_gradient(width, height);
834
+ return PhotonImage.__wrap(ret);
835
+ }
836
+
837
+ /**
838
+ * Crop an image.
839
+ *
840
+ * # Arguments
841
+ * * `img` - A PhotonImage.
842
+ *
843
+ * # Example
844
+ *
845
+ * ```no_run
846
+ * // For example, to crop an image at (0, 0) to (500, 800)
847
+ * use photon_rs::native::{open_image};
848
+ * use photon_rs::transform::crop;
849
+ * use photon_rs::PhotonImage;
850
+ *
851
+ * let mut img = open_image("img.jpg").expect("File should open");
852
+ * let cropped_img: PhotonImage = crop(&img, 0_u32, 0_u32, 500_u32, 800_u32);
853
+ * // Write the contents of this image in JPG format.
854
+ * ```
855
+ * @param {PhotonImage} photon_image
856
+ * @param {number} x1
857
+ * @param {number} y1
858
+ * @param {number} x2
859
+ * @param {number} y2
860
+ * @returns {PhotonImage}
861
+ */
862
+ export function crop(photon_image, x1, y1, x2, y2) {
863
+ _assertClass(photon_image, PhotonImage);
864
+ const ret = wasm.crop(photon_image.__wbg_ptr, x1, y1, x2, y2);
865
+ return PhotonImage.__wrap(ret);
866
+ }
867
+
868
+ /**
869
+ * @param {HTMLCanvasElement} source_canvas
870
+ * @param {number} width
871
+ * @param {number} height
872
+ * @param {number} left
873
+ * @param {number} top
874
+ * @returns {HTMLCanvasElement}
875
+ */
876
+ export function crop_img_browser(source_canvas, width, height, left, top) {
877
+ const ret = wasm.crop_img_browser(source_canvas, width, height, left, top);
878
+ return ret;
879
+ }
880
+
881
+ /**
882
+ * Darken the image by a specified amount in the HSL colour space.
883
+ *
884
+ * # Arguments
885
+ * * `img` - A PhotonImage.
886
+ * * `level` - Float value from 0 to 1 representing the level to which to darken the image by.
887
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
888
+ * Darkening by 80% would be represented by a `level` of 0.8
889
+ *
890
+ * # Example
891
+ * ```no_run
892
+ * // For example to darken an image by 10% in the HSL colour space:
893
+ * use photon_rs::colour_spaces::darken_hsl;
894
+ * use photon_rs::native::open_image;
895
+ *
896
+ * // Open the image. A PhotonImage is returned.
897
+ * let mut img = open_image("img.jpg").expect("File should open");
898
+ * darken_hsl(&mut img, 0.1_f32);
899
+ * ```
900
+ * @param {PhotonImage} img
901
+ * @param {number} level
902
+ */
903
+ export function darken_hsl(img, level) {
904
+ _assertClass(img, PhotonImage);
905
+ wasm.darken_hsl(img.__wbg_ptr, level);
906
+ }
907
+
908
+ /**
909
+ * Darken the image by a specified amount in the HSLuv colour space.
910
+ *
911
+ * # Arguments
912
+ * * `img` - A PhotonImage.
913
+ * * `level` - Float value from 0 to 1 representing the level to which to darken the image by.
914
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
915
+ * Darkening by 80% would be represented by a `level` of 0.8
916
+ *
917
+ * # Example
918
+ * ```no_run
919
+ * // For example to darken an image by 10% in the HSLuv colour space:
920
+ * use photon_rs::colour_spaces::darken_hsluv;
921
+ * use photon_rs::native::open_image;
922
+ *
923
+ * // Open the image. A PhotonImage is returned.
924
+ * let mut img = open_image("img.jpg").expect("File should open");
925
+ * darken_hsluv(&mut img, 0.1_f32);
926
+ * ```
927
+ * @param {PhotonImage} img
928
+ * @param {number} level
929
+ */
930
+ export function darken_hsluv(img, level) {
931
+ _assertClass(img, PhotonImage);
932
+ wasm.darken_hsluv(img.__wbg_ptr, level);
933
+ }
934
+
935
+ /**
936
+ * Darken the image's colours by a specified amount in the HSV colour space.
937
+ *
938
+ * # Arguments
939
+ * * `img` - A PhotonImage.
940
+ * * `level` - Float value from 0 to 1 representing the level to which to darken the image by.
941
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
942
+ * Darkening by 80% would be represented by a `level` of 0.8
943
+ *
944
+ * # Example
945
+ * ```no_run
946
+ * // For example to darken an image by 10% in the HSV colour space:
947
+ * use photon_rs::colour_spaces::darken_hsv;
948
+ * use photon_rs::native::open_image;
949
+ *
950
+ * // Open the image. A PhotonImage is returned.
951
+ * let mut img = open_image("img.jpg").expect("File should open");
952
+ * darken_hsv(&mut img, 0.1_f32);
953
+ * ```
954
+ * @param {PhotonImage} img
955
+ * @param {number} level
956
+ */
957
+ export function darken_hsv(img, level) {
958
+ _assertClass(img, PhotonImage);
959
+ wasm.darken_hsv(img.__wbg_ptr, level);
960
+ }
961
+
962
+ /**
963
+ * Darken the image by a specified amount in the LCh colour space.
964
+ *
965
+ * # Arguments
966
+ * * `img` - A PhotonImage.
967
+ * * `level` - Float value from 0 to 1 representing the level to which to darken the image by.
968
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
969
+ * Darkening by 80% would be represented by a `level` of 0.8
970
+ *
971
+ * # Example
972
+ * ```no_run
973
+ * // For example to darken an image by 10% in the LCh colour space:
974
+ * use photon_rs::colour_spaces::darken_lch;
975
+ * use photon_rs::native::open_image;
976
+ *
977
+ * // Open the image. A PhotonImage is returned.
978
+ * let mut img = open_image("img.jpg").expect("File should open");
979
+ * darken_lch(&mut img, 0.1_f32);
980
+ * ```
981
+ * @param {PhotonImage} img
982
+ * @param {number} level
983
+ */
984
+ export function darken_lch(img, level) {
985
+ _assertClass(img, PhotonImage);
986
+ wasm.darken_lch(img.__wbg_ptr, level);
987
+ }
988
+
989
+ /**
990
+ * Decrease the brightness of an image by a constant.
991
+ *
992
+ * # Arguments
993
+ * * `img` - A PhotonImage that contains a view into the image.
994
+ * * `brightness` - A u8 to subtract from the brightness. It should be a positive number,
995
+ * and this value will then be subtracted from the brightness.
996
+ * # Example
997
+ *
998
+ * ```no_run
999
+ * use photon_rs::effects::dec_brightness;
1000
+ * use photon_rs::native::open_image;
1001
+ *
1002
+ * let mut img = open_image("img.jpg").expect("File should open");
1003
+ * dec_brightness(&mut img, 10_u8);
1004
+ * ```
1005
+ * @param {PhotonImage} photon_image
1006
+ * @param {number} brightness
1007
+ */
1008
+ export function dec_brightness(photon_image, brightness) {
1009
+ _assertClass(photon_image, PhotonImage);
1010
+ wasm.dec_brightness(photon_image.__wbg_ptr, brightness);
1011
+ }
1012
+
1013
+ /**
1014
+ * Uses a max. decomposition algorithm to convert an image to greyscale.
1015
+ *
1016
+ * # Arguments
1017
+ * * `photon_image` - A PhotonImage.
1018
+ *
1019
+ * # Example
1020
+ *
1021
+ * ```no_run
1022
+ * // For example, to decompose an image with max decomposition:
1023
+ * use photon_rs::monochrome::decompose_max;
1024
+ * use photon_rs::native::open_image;
1025
+ *
1026
+ * let mut img = open_image("img.jpg").expect("File should open");
1027
+ * decompose_max(&mut img);
1028
+ * ```
1029
+ * @param {PhotonImage} img
1030
+ */
1031
+ export function decompose_max(img) {
1032
+ _assertClass(img, PhotonImage);
1033
+ wasm.decompose_max(img.__wbg_ptr);
1034
+ }
1035
+
1036
+ /**
1037
+ * Uses a min. decomposition algorithm to convert an image to greyscale.
1038
+ *
1039
+ * # Arguments
1040
+ * * `photon_image` - A PhotonImage.
1041
+ *
1042
+ * # Example
1043
+ *
1044
+ * ```no_run
1045
+ * // For example, to decompose an image with min decomposition:
1046
+ * use photon_rs::monochrome::decompose_min;
1047
+ * use photon_rs::native::open_image;
1048
+ *
1049
+ * let mut img = open_image("img.jpg").expect("File should open");
1050
+ * decompose_min(&mut img);
1051
+ * ```
1052
+ * @param {PhotonImage} img
1053
+ */
1054
+ export function decompose_min(img) {
1055
+ _assertClass(img, PhotonImage);
1056
+ wasm.decompose_min(img.__wbg_ptr);
1057
+ }
1058
+
1059
+ /**
1060
+ * Desaturate an image by getting the min/max of each pixel's RGB values.
1061
+ *
1062
+ * # Arguments
1063
+ * * `photon_image` - A PhotonImage.
1064
+ * # Example
1065
+ *
1066
+ * ```no_run
1067
+ * // For example, to desaturate an image:
1068
+ * use photon_rs::monochrome::desaturate;
1069
+ * use photon_rs::native::open_image;
1070
+ *
1071
+ * let mut img = open_image("img.jpg").expect("File should open");
1072
+ * desaturate(&mut img);
1073
+ * ```
1074
+ * @param {PhotonImage} img
1075
+ */
1076
+ export function desaturate(img) {
1077
+ _assertClass(img, PhotonImage);
1078
+ wasm.desaturate(img.__wbg_ptr);
1079
+ }
1080
+
1081
+ /**
1082
+ * Desaturate the image by a specified amount in the HSL colour space.
1083
+ *
1084
+ * # Arguments
1085
+ * * `img` - A PhotonImage.
1086
+ * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by.
1087
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
1088
+ * Desaturating by 80% would be represented by a `level` of 0.8
1089
+ *
1090
+ * # Example
1091
+ * ```no_run
1092
+ * // For example to desaturate an image by 10% in the LCh colour space:
1093
+ * use photon_rs::colour_spaces::desaturate_hsl;
1094
+ * use photon_rs::native::open_image;
1095
+ *
1096
+ * // Open the image. A PhotonImage is returned.
1097
+ * let mut img = open_image("img.jpg").expect("File should open");
1098
+ * desaturate_hsl(&mut img, 0.1_f32);
1099
+ * ```
1100
+ * @param {PhotonImage} img
1101
+ * @param {number} level
1102
+ */
1103
+ export function desaturate_hsl(img, level) {
1104
+ _assertClass(img, PhotonImage);
1105
+ wasm.desaturate_hsl(img.__wbg_ptr, level);
1106
+ }
1107
+
1108
+ /**
1109
+ * Desaturate the image by a specified amount in the HSLuv colour space.
1110
+ *
1111
+ * # Arguments
1112
+ * * `img` - A PhotonImage.
1113
+ * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by.
1114
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
1115
+ * Desaturating by 80% would be represented by a `level` of 0.8
1116
+ *
1117
+ * # Example
1118
+ * ```no_run
1119
+ * // For example to desaturate an image by 10% in the HSLuv colour space:
1120
+ * use photon_rs::colour_spaces::desaturate_hsluv;
1121
+ * use photon_rs::native::open_image;
1122
+ *
1123
+ * // Open the image. A PhotonImage is returned.
1124
+ * let mut img = open_image("img.jpg").expect("File should open");
1125
+ * desaturate_hsluv(&mut img, 0.1_f32);
1126
+ * ```
1127
+ * @param {PhotonImage} img
1128
+ * @param {number} level
1129
+ */
1130
+ export function desaturate_hsluv(img, level) {
1131
+ _assertClass(img, PhotonImage);
1132
+ wasm.desaturate_hsluv(img.__wbg_ptr, level);
1133
+ }
1134
+
1135
+ /**
1136
+ * Desaturate the image by a specified amount in the HSV colour space.
1137
+ *
1138
+ * # Arguments
1139
+ * * `img` - A PhotonImage.
1140
+ * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by.
1141
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
1142
+ * Desaturating by 80% would be represented by a `level` of 0.8
1143
+ *
1144
+ * # Example
1145
+ * ```no_run
1146
+ * // For example to desaturate an image by 10% in the HSV colour space:
1147
+ * use photon_rs::colour_spaces::desaturate_hsv;
1148
+ * use photon_rs::native::open_image;
1149
+ *
1150
+ * // Open the image. A PhotonImage is returned.
1151
+ * let mut img = open_image("img.jpg").expect("File should open");
1152
+ * desaturate_hsv(&mut img, 0.1_f32);
1153
+ * ```
1154
+ * @param {PhotonImage} img
1155
+ * @param {number} level
1156
+ */
1157
+ export function desaturate_hsv(img, level) {
1158
+ _assertClass(img, PhotonImage);
1159
+ wasm.desaturate_hsv(img.__wbg_ptr, level);
1160
+ }
1161
+
1162
+ /**
1163
+ * Desaturate the image by a specified amount in the LCh colour space.
1164
+ *
1165
+ * # Arguments
1166
+ * * `img` - A PhotonImage.
1167
+ * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by.
1168
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
1169
+ * Desaturating by 80% would be represented by a `level` of 0.8
1170
+ *
1171
+ * # Example
1172
+ * ```no_run
1173
+ * // For example to desaturate an image by 10% in the LCh colour space:
1174
+ * use photon_rs::colour_spaces::desaturate_lch;
1175
+ * use photon_rs::native::open_image;
1176
+ *
1177
+ * // Open the image. A PhotonImage is returned.
1178
+ * let mut img = open_image("img.jpg").expect("File should open");
1179
+ * desaturate_lch(&mut img, 0.1_f32);
1180
+ * ```
1181
+ * @param {PhotonImage} img
1182
+ * @param {number} level
1183
+ */
1184
+ export function desaturate_lch(img, level) {
1185
+ _assertClass(img, PhotonImage);
1186
+ wasm.desaturate_lch(img.__wbg_ptr, level);
1187
+ }
1188
+
1189
+ /**
1190
+ * Detect lines at a 135 degree angle in an image, and highlight these only.
1191
+ *
1192
+ * # Arguments
1193
+ * * `img` - A PhotonImage.
1194
+ *
1195
+ * # Example
1196
+ *
1197
+ * ```no_run
1198
+ * // For example, to display the lines at a 135 degree angle in an image:
1199
+ * use photon_rs::conv::detect_135_deg_lines;
1200
+ * use photon_rs::native::open_image;
1201
+ *
1202
+ * let mut img = open_image("img.jpg").expect("File should open");
1203
+ * detect_135_deg_lines(&mut img);
1204
+ * ```
1205
+ * @param {PhotonImage} photon_image
1206
+ */
1207
+ export function detect_135_deg_lines(photon_image) {
1208
+ _assertClass(photon_image, PhotonImage);
1209
+ wasm.detect_135_deg_lines(photon_image.__wbg_ptr);
1210
+ }
1211
+
1212
+ /**
1213
+ * Detect lines at a forty five degree angle in an image, and highlight these only.
1214
+ *
1215
+ * # Arguments
1216
+ * * `img` - A PhotonImage.
1217
+ *
1218
+ * # Example
1219
+ *
1220
+ * ```no_run
1221
+ * // For example, to display the lines at a forty five degree angle in an image:
1222
+ * use photon_rs::conv::detect_45_deg_lines;
1223
+ * use photon_rs::native::open_image;
1224
+ *
1225
+ * let mut img = open_image("img.jpg").expect("File should open");
1226
+ * detect_45_deg_lines(&mut img);
1227
+ * ```
1228
+ * @param {PhotonImage} photon_image
1229
+ */
1230
+ export function detect_45_deg_lines(photon_image) {
1231
+ _assertClass(photon_image, PhotonImage);
1232
+ wasm.detect_45_deg_lines(photon_image.__wbg_ptr);
1233
+ }
1234
+
1235
+ /**
1236
+ * Detect horizontal lines in an image, and highlight these only.
1237
+ *
1238
+ * # Arguments
1239
+ * * `img` - A PhotonImage.
1240
+ *
1241
+ * # Example
1242
+ *
1243
+ * ```no_run
1244
+ * // For example, to display the horizontal lines in an image:
1245
+ * use photon_rs::conv::detect_horizontal_lines;
1246
+ * use photon_rs::native::open_image;
1247
+ *
1248
+ * let mut img = open_image("img.jpg").expect("File should open");
1249
+ * detect_horizontal_lines(&mut img);
1250
+ * ```
1251
+ * @param {PhotonImage} photon_image
1252
+ */
1253
+ export function detect_horizontal_lines(photon_image) {
1254
+ _assertClass(photon_image, PhotonImage);
1255
+ wasm.detect_horizontal_lines(photon_image.__wbg_ptr);
1256
+ }
1257
+
1258
+ /**
1259
+ * Detect vertical lines in an image, and highlight these only.
1260
+ *
1261
+ * # Arguments
1262
+ * * `img` - A PhotonImage.
1263
+ *
1264
+ * # Example
1265
+ *
1266
+ * ```no_run
1267
+ * // For example, to display the vertical lines in an image:
1268
+ * use photon_rs::conv::detect_vertical_lines;
1269
+ * use photon_rs::native::open_image;
1270
+ *
1271
+ * let mut img = open_image("img.jpg").expect("File should open");
1272
+ * detect_vertical_lines(&mut img);
1273
+ * ```
1274
+ * @param {PhotonImage} photon_image
1275
+ */
1276
+ export function detect_vertical_lines(photon_image) {
1277
+ _assertClass(photon_image, PhotonImage);
1278
+ wasm.detect_vertical_lines(photon_image.__wbg_ptr);
1279
+ }
1280
+
1281
+ /**
1282
+ * Applies Floyd-Steinberg dithering to an image.
1283
+ * Only RGB channels are processed, alpha remains unchanged.
1284
+ * # Arguments
1285
+ * * `photon_image` - A PhotonImage that contains a view into the image.
1286
+ * * `depth` - bits per channel. Clamped between 1 and 8.
1287
+ * # Example
1288
+ *
1289
+ * ```no_run
1290
+ * // For example, to turn an image of type `PhotonImage` into a dithered image:
1291
+ * use photon_rs::effects::dither;
1292
+ * use photon_rs::native::open_image;
1293
+ *
1294
+ * let mut img = open_image("img.jpg").expect("File should open");
1295
+ * let depth = 1;
1296
+ * dither(&mut img, depth);
1297
+ * ```
1298
+ * @param {PhotonImage} photon_image
1299
+ * @param {number} depth
1300
+ */
1301
+ export function dither(photon_image, depth) {
1302
+ _assertClass(photon_image, PhotonImage);
1303
+ wasm.dither(photon_image.__wbg_ptr, depth);
1304
+ }
1305
+
1306
+ /**
1307
+ * Greyscale effect with increased contrast.
1308
+ *
1309
+ * # Arguments
1310
+ * * `img` - A PhotonImage.
1311
+ * # Example
1312
+ *
1313
+ * ```no_run
1314
+ * use photon_rs::filters::dramatic;
1315
+ * use photon_rs::native::open_image;
1316
+ *
1317
+ * let mut img = open_image("img.jpg").expect("File should open");
1318
+ * dramatic(&mut img);
1319
+ * ```
1320
+ * @param {PhotonImage} img
1321
+ */
1322
+ export function dramatic(img) {
1323
+ _assertClass(img, PhotonImage);
1324
+ wasm.dramatic(img.__wbg_ptr);
1325
+ }
1326
+
1327
+ /**
1328
+ * Add text to an image.
1329
+ * The only font available as of now is Roboto.
1330
+ * Note: A graphic design/text-drawing library is currently being developed, so stay tuned.
1331
+ *
1332
+ * # Arguments
1333
+ * * `photon_image` - A PhotonImage.
1334
+ * * `text` - Text string to be drawn to the image.
1335
+ * * `x` - x-coordinate of where first letter's 1st pixel should be drawn.
1336
+ * * `y` - y-coordinate of where first letter's 1st pixel should be drawn.
1337
+ * * `font_size` - Font size in pixels of the text to be drawn.
1338
+ *
1339
+ * # Example
1340
+ *
1341
+ * ```no_run
1342
+ * // For example to draw the string "Welcome to Photon!" at 10, 10:
1343
+ * use photon_rs::native::open_image;
1344
+ * use photon_rs::text::draw_text;
1345
+ *
1346
+ * // Open the image. A PhotonImage is returned.
1347
+ * let mut img = open_image("img.jpg").expect("File should open");
1348
+ * draw_text(&mut img, "Welcome to Photon!", 10_i32, 10_i32, 90_f32);
1349
+ * ```
1350
+ * @param {PhotonImage} photon_img
1351
+ * @param {string} text
1352
+ * @param {number} x
1353
+ * @param {number} y
1354
+ * @param {number} font_size
1355
+ */
1356
+ export function draw_text(photon_img, text, x, y, font_size) {
1357
+ _assertClass(photon_img, PhotonImage);
1358
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1359
+ const len0 = WASM_VECTOR_LEN;
1360
+ wasm.draw_text(photon_img.__wbg_ptr, ptr0, len0, x, y, font_size);
1361
+ }
1362
+
1363
+ /**
1364
+ * Add bordered-text to an image.
1365
+ * The only font available as of now is Roboto.
1366
+ * Note: A graphic design/text-drawing library is currently being developed, so stay tuned.
1367
+ *
1368
+ * # Arguments
1369
+ * * `photon_image` - A PhotonImage.
1370
+ * * `text` - Text string to be drawn to the image.
1371
+ * * `x` - x-coordinate of where first letter's 1st pixel should be drawn.
1372
+ * * `y` - y-coordinate of where first letter's 1st pixel should be drawn.
1373
+ * * `font_size` - Font size in pixels of the text to be drawn.
1374
+ *
1375
+ * # Example
1376
+ *
1377
+ * ```no_run
1378
+ * // For example to draw the string "Welcome to Photon!" at 10, 10:
1379
+ * use photon_rs::native::open_image;
1380
+ * use photon_rs::text::draw_text_with_border;
1381
+ *
1382
+ * // Open the image. A PhotonImage is returned.
1383
+ * let mut img = open_image("img.jpg").expect("File should open");
1384
+ * draw_text_with_border(&mut img, "Welcome to Photon!", 10_i32, 10_i32, 90_f32);
1385
+ * ```
1386
+ * @param {PhotonImage} photon_img
1387
+ * @param {string} text
1388
+ * @param {number} x
1389
+ * @param {number} y
1390
+ * @param {number} font_size
1391
+ */
1392
+ export function draw_text_with_border(photon_img, text, x, y, font_size) {
1393
+ _assertClass(photon_img, PhotonImage);
1394
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1395
+ const len0 = WASM_VECTOR_LEN;
1396
+ wasm.draw_text_with_border(photon_img.__wbg_ptr, ptr0, len0, x, y, font_size);
1397
+ }
1398
+
1399
+ /**
1400
+ * @param {PhotonImage} photon_image
1401
+ * @param {Rgb} color_a
1402
+ * @param {Rgb} color_b
1403
+ */
1404
+ export function duotone(photon_image, color_a, color_b) {
1405
+ _assertClass(photon_image, PhotonImage);
1406
+ _assertClass(color_a, Rgb);
1407
+ var ptr0 = color_a.__destroy_into_raw();
1408
+ _assertClass(color_b, Rgb);
1409
+ var ptr1 = color_b.__destroy_into_raw();
1410
+ wasm.duotone(photon_image.__wbg_ptr, ptr0, ptr1);
1411
+ }
1412
+
1413
+ /**
1414
+ * Duotone effect with purple tones.
1415
+ *
1416
+ * # Arguments
1417
+ * * `img` - A PhotonImage.
1418
+ * # Example
1419
+ *
1420
+ * ```no_run
1421
+ * use photon_rs::filters::duotone_horizon;
1422
+ * use photon_rs::native::open_image;
1423
+ *
1424
+ * let mut img = open_image("img.jpg").expect("File should open");
1425
+ * duotone_horizon(&mut img);
1426
+ * ```
1427
+ * @param {PhotonImage} img
1428
+ */
1429
+ export function duotone_horizon(img) {
1430
+ _assertClass(img, PhotonImage);
1431
+ wasm.duotone_horizon(img.__wbg_ptr);
1432
+ }
1433
+
1434
+ /**
1435
+ * Duotone effect with a lilac hue
1436
+ *
1437
+ * # Arguments
1438
+ * * `img` - A PhotonImage.
1439
+ * # Example
1440
+ *
1441
+ * ```no_run
1442
+ * use photon_rs::filters::duotone_lilac;
1443
+ * use photon_rs::native::open_image;
1444
+ *
1445
+ * let mut img = open_image("img.jpg").expect("File should open");
1446
+ * duotone_lilac(&mut img);
1447
+ * ```
1448
+ * @param {PhotonImage} img
1449
+ */
1450
+ export function duotone_lilac(img) {
1451
+ _assertClass(img, PhotonImage);
1452
+ wasm.duotone_lilac(img.__wbg_ptr);
1453
+ }
1454
+
1455
+ /**
1456
+ * A duotone ochre tint effect
1457
+ *
1458
+ * # Arguments
1459
+ * * `img` - A PhotonImage.
1460
+ * # Example
1461
+ *
1462
+ * ```no_run
1463
+ * use photon_rs::filters::duotone_ochre;
1464
+ * use photon_rs::native::open_image;
1465
+ *
1466
+ * let mut img = open_image("img.jpg").expect("File should open");
1467
+ * duotone_ochre(&mut img);
1468
+ * ```
1469
+ * @param {PhotonImage} img
1470
+ */
1471
+ export function duotone_ochre(img) {
1472
+ _assertClass(img, PhotonImage);
1473
+ wasm.duotone_ochre(img.__wbg_ptr);
1474
+ }
1475
+
1476
+ /**
1477
+ * A duotone filter with a user-specified color and a gray color
1478
+ *
1479
+ * # Arguments
1480
+ * * `img` - A PhotonImage.
1481
+ * * `rgb_color` - RGB color
1482
+ * # Example
1483
+ *
1484
+ * ```no_run
1485
+ * use photon_rs::filters::duotone_tint;
1486
+ * use photon_rs::native::open_image;
1487
+ * use photon_rs::Rgb;
1488
+ *
1489
+ * let mut img = open_image("img.jpg").expect("File should open");
1490
+ * let rgb_color = Rgb::new(12, 12, 10);
1491
+ * duotone_tint(&mut img, rgb_color);
1492
+ * ```
1493
+ * @param {PhotonImage} img
1494
+ * @param {Rgb} rgb_color
1495
+ */
1496
+ export function duotone_tint(img, rgb_color) {
1497
+ _assertClass(img, PhotonImage);
1498
+ _assertClass(rgb_color, Rgb);
1499
+ var ptr0 = rgb_color.__destroy_into_raw();
1500
+ wasm.duotone_tint(img.__wbg_ptr, ptr0);
1501
+ }
1502
+
1503
+ /**
1504
+ * Duotone effect with blue and purple tones.
1505
+ *
1506
+ * # Arguments
1507
+ * * `img` - A PhotonImage.
1508
+ * # Example
1509
+ *
1510
+ * ```no_run
1511
+ * use photon_rs::filters::duotone_violette;
1512
+ * use photon_rs::native::open_image;
1513
+ *
1514
+ * let mut img = open_image("img.jpg").expect("File should open");
1515
+ * duotone_violette(&mut img);
1516
+ * ```
1517
+ * @param {PhotonImage} img
1518
+ */
1519
+ export function duotone_violette(img) {
1520
+ _assertClass(img, PhotonImage);
1521
+ wasm.duotone_violette(img.__wbg_ptr);
1522
+ }
1523
+
1524
+ /**
1525
+ * Apply edge detection to an image, to create a dark version with its edges highlighted.
1526
+ *
1527
+ * # Arguments
1528
+ * * `img` - A PhotonImage.
1529
+ *
1530
+ * # Example
1531
+ *
1532
+ * ```no_run
1533
+ * // For example, to increase the Red channel for all pixels by 10:
1534
+ * use photon_rs::conv::edge_detection;
1535
+ * use photon_rs::native::open_image;
1536
+ *
1537
+ * let mut img = open_image("img.jpg").expect("File should open");
1538
+ * edge_detection(&mut img);
1539
+ * ```
1540
+ * @param {PhotonImage} photon_image
1541
+ */
1542
+ export function edge_detection(photon_image) {
1543
+ _assertClass(photon_image, PhotonImage);
1544
+ wasm.edge_detection(photon_image.__wbg_ptr);
1545
+ }
1546
+
1547
+ /**
1548
+ * Preset edge effect.
1549
+ *
1550
+ * # Arguments
1551
+ * * `img` - A PhotonImage.
1552
+ *
1553
+ * # Example
1554
+ *
1555
+ * ```no_run
1556
+ * // For example, to apply this effect:
1557
+ * use photon_rs::conv::edge_one;
1558
+ * use photon_rs::native::open_image;
1559
+ *
1560
+ * let mut img = open_image("img.jpg").expect("File should open");
1561
+ * edge_one(&mut img);
1562
+ * ```
1563
+ * @param {PhotonImage} photon_image
1564
+ */
1565
+ export function edge_one(photon_image) {
1566
+ _assertClass(photon_image, PhotonImage);
1567
+ wasm.edge_one(photon_image.__wbg_ptr);
1568
+ }
1569
+
1570
+ /**
1571
+ * Apply an emboss effect to an image.
1572
+ *
1573
+ * # Arguments
1574
+ * * `img` - A PhotonImage.
1575
+ *
1576
+ * # Example
1577
+ *
1578
+ * ```no_run
1579
+ * // For example, to apply an emboss effect:
1580
+ * use photon_rs::conv::emboss;
1581
+ * use photon_rs::native::open_image;
1582
+ *
1583
+ * let mut img = open_image("img.jpg").expect("File should open");
1584
+ * emboss(&mut img);
1585
+ * ```
1586
+ * @param {PhotonImage} photon_image
1587
+ */
1588
+ export function emboss(photon_image) {
1589
+ _assertClass(photon_image, PhotonImage);
1590
+ wasm.emboss(photon_image.__wbg_ptr);
1591
+ }
1592
+
1593
+ /**
1594
+ * Apply a filter to an image. Over 20 filters are available.
1595
+ * The filters are as follows:
1596
+ * * **oceanic**: Add an aquamarine-tinted hue to an image.
1597
+ * * **islands**: Aquamarine tint.
1598
+ * * **marine**: Add a green/blue mixed hue to an image.
1599
+ * * **seagreen**: Dark green hue, with tones of blue.
1600
+ * * **flagblue**: Royal blue tint
1601
+ * * **liquid**: Blue-inspired tint.
1602
+ * * **diamante**: Custom filter with a blue/turquoise tint.
1603
+ * * **radio**: Fallout-style radio effect.
1604
+ * * **twenties**: Slight-blue tinted historical effect.
1605
+ * * **rosetint**: Rose-tinted filter.
1606
+ * * **mauve**: Purple-infused filter.
1607
+ * * **bluechrome**: Blue monochrome effect.
1608
+ * * **vintage**: Vintage filter with a red tint.
1609
+ * * **perfume**: Increase the blue channel, with moderate increases in the Red and Green channels.
1610
+ * * **serenity**: Custom filter with an increase in the Blue channel's values.
1611
+ * # Arguments
1612
+ * * `img` - A PhotonImage.
1613
+ * * `filter_name` - The filter's name. Choose from the selection above, eg: "oceanic"
1614
+ * # Example
1615
+ *
1616
+ * ```no_run
1617
+ * // For example, to add a filter called "vintage" to an image:
1618
+ * use photon_rs::filters::filter;
1619
+ * use photon_rs::native::open_image;
1620
+ *
1621
+ * let mut img = open_image("img.jpg").expect("File should open");
1622
+ * filter(&mut img, "vintage");
1623
+ * ```
1624
+ * @param {PhotonImage} img
1625
+ * @param {string} filter_name
1626
+ */
1627
+ export function filter(img, filter_name) {
1628
+ _assertClass(img, PhotonImage);
1629
+ const ptr0 = passStringToWasm0(filter_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1630
+ const len0 = WASM_VECTOR_LEN;
1631
+ wasm.filter(img.__wbg_ptr, ptr0, len0);
1632
+ }
1633
+
1634
+ /**
1635
+ * Apply a red hue, with increased contrast and brightness.
1636
+ *
1637
+ * # Arguments
1638
+ * * `img` - A PhotonImage.
1639
+ * # Example
1640
+ *
1641
+ * ```no_run
1642
+ * use photon_rs::filters::firenze;
1643
+ * use photon_rs::native::open_image;
1644
+ *
1645
+ * let mut img = open_image("img.jpg").expect("File should open");
1646
+ * firenze(&mut img);
1647
+ * ```
1648
+ * @param {PhotonImage} img
1649
+ */
1650
+ export function firenze(img) {
1651
+ _assertClass(img, PhotonImage);
1652
+ wasm.firenze(img.__wbg_ptr);
1653
+ }
1654
+
1655
+ /**
1656
+ * Flip an image horizontally.
1657
+ *
1658
+ * # Arguments
1659
+ * * `img` - A PhotonImage.
1660
+ *
1661
+ * # Example
1662
+ *
1663
+ * ```no_run
1664
+ * // For example, to flip an image horizontally:
1665
+ * use photon_rs::native::open_image;
1666
+ * use photon_rs::transform::fliph;
1667
+ *
1668
+ * let mut img = open_image("img.jpg").expect("File should open");
1669
+ * fliph(&mut img);
1670
+ * ```
1671
+ * @param {PhotonImage} photon_image
1672
+ */
1673
+ export function fliph(photon_image) {
1674
+ _assertClass(photon_image, PhotonImage);
1675
+ wasm.fliph(photon_image.__wbg_ptr);
1676
+ }
1677
+
1678
+ /**
1679
+ * Flip an image vertically.
1680
+ *
1681
+ * # Arguments
1682
+ * * `img` - A PhotonImage.
1683
+ *
1684
+ * # Example
1685
+ *
1686
+ * ```no_run
1687
+ * // For example, to flip an image vertically:
1688
+ * use photon_rs::native::open_image;
1689
+ * use photon_rs::transform::flipv;
1690
+ *
1691
+ * let mut img = open_image("img.jpg").expect("File should open");
1692
+ * flipv(&mut img);
1693
+ * ```
1694
+ * @param {PhotonImage} photon_image
1695
+ */
1696
+ export function flipv(photon_image) {
1697
+ _assertClass(photon_image, PhotonImage);
1698
+ wasm.flipv(photon_image.__wbg_ptr);
1699
+ }
1700
+
1701
+ /**
1702
+ * Turn an image into an frosted glass see through
1703
+ *
1704
+ * # Arguments
1705
+ * * `img` - A PhotonImage that contains a view into the image.
1706
+ * # Example
1707
+ *
1708
+ * ```no_run
1709
+ * // For example, to turn an image of type `PhotonImage` into frosted glass see through:
1710
+ * use photon_rs::effects::frosted_glass;
1711
+ * use photon_rs::native::open_image;
1712
+ *
1713
+ * let mut img = open_image("img.jpg").expect("File should open");
1714
+ * frosted_glass(&mut img);
1715
+ * ```
1716
+ * @param {PhotonImage} photon_image
1717
+ */
1718
+ export function frosted_glass(photon_image) {
1719
+ _assertClass(photon_image, PhotonImage);
1720
+ wasm.frosted_glass(photon_image.__wbg_ptr);
1721
+ }
1722
+
1723
+ /**
1724
+ * Convert an image to grayscale by setting a pixel's 3 RGB values to the Green channel's value.
1725
+ *
1726
+ * # Arguments
1727
+ * * `photon_image` - A PhotonImage.
1728
+ *
1729
+ * # Example
1730
+ *
1731
+ * ```no_run
1732
+ * use photon_rs::monochrome::g_grayscale;
1733
+ * use photon_rs::native::open_image;
1734
+ *
1735
+ * let mut img = open_image("img.jpg").expect("File should open");
1736
+ * g_grayscale(&mut img);
1737
+ * ```
1738
+ * @param {PhotonImage} photon_image
1739
+ */
1740
+ export function g_grayscale(photon_image) {
1741
+ _assertClass(photon_image, PhotonImage);
1742
+ wasm.g_grayscale(photon_image.__wbg_ptr);
1743
+ }
1744
+
1745
+ /**
1746
+ * Applies gamma correction to an image.
1747
+ * # Arguments
1748
+ * * `photon_image` - A PhotonImage that contains a view into the image.
1749
+ * * `red` - Gamma value for red channel.
1750
+ * * `green` - Gamma value for green channel.
1751
+ * * `blue` - Gamma value for blue channel.
1752
+ * # Example
1753
+ *
1754
+ * ```no_run
1755
+ * // For example, to turn an image of type `PhotonImage` into a gamma corrected image:
1756
+ * use photon_rs::colour_spaces::gamma_correction;
1757
+ * use photon_rs::native::open_image;
1758
+ *
1759
+ * let mut img = open_image("img.jpg").expect("File should open");
1760
+ * gamma_correction(&mut img, 2.2, 2.2, 2.2);
1761
+ * ```
1762
+ * @param {PhotonImage} photon_image
1763
+ * @param {number} red
1764
+ * @param {number} green
1765
+ * @param {number} blue
1766
+ */
1767
+ export function gamma_correction(photon_image, red, green, blue) {
1768
+ _assertClass(photon_image, PhotonImage);
1769
+ wasm.gamma_correction(photon_image.__wbg_ptr, red, green, blue);
1770
+ }
1771
+
1772
+ /**
1773
+ * Gaussian blur in linear time.
1774
+ *
1775
+ * Reference: http://blog.ivank.net/fastest-gaussian-blur.html
1776
+ *
1777
+ * # Arguments
1778
+ * * `photon_image` - A PhotonImage
1779
+ * * `radius` - blur radius
1780
+ * # Example
1781
+ *
1782
+ * ```no_run
1783
+ * use photon_rs::conv::gaussian_blur;
1784
+ * use photon_rs::native::open_image;
1785
+ *
1786
+ * let mut img = open_image("img.jpg").expect("File should open");
1787
+ * gaussian_blur(&mut img, 3_i32);
1788
+ * ```
1789
+ * @param {PhotonImage} photon_image
1790
+ * @param {number} radius
1791
+ */
1792
+ export function gaussian_blur(photon_image, radius) {
1793
+ _assertClass(photon_image, PhotonImage);
1794
+ wasm.gaussian_blur(photon_image.__wbg_ptr, radius);
1795
+ }
1796
+
1797
+ /**
1798
+ * Get the ImageData from a 2D canvas context
1799
+ * @param {HTMLCanvasElement} canvas
1800
+ * @param {CanvasRenderingContext2D} ctx
1801
+ * @returns {ImageData}
1802
+ */
1803
+ export function get_image_data(canvas, ctx) {
1804
+ const ret = wasm.get_image_data(canvas, ctx);
1805
+ return ret;
1806
+ }
1807
+
1808
+ /**
1809
+ * Apply a vintage, golden hue to an image.
1810
+ *
1811
+ * # Arguments
1812
+ * * `img` - A PhotonImage.
1813
+ * # Example
1814
+ *
1815
+ * ```no_run
1816
+ * use photon_rs::filters::golden;
1817
+ * use photon_rs::native::open_image;
1818
+ *
1819
+ * let mut img = open_image("img.jpg").expect("File should open");
1820
+ * golden(&mut img);
1821
+ * ```
1822
+ * @param {PhotonImage} img
1823
+ */
1824
+ export function golden(img) {
1825
+ _assertClass(img, PhotonImage);
1826
+ wasm.golden(img.__wbg_ptr);
1827
+ }
1828
+
1829
+ /**
1830
+ * Convert an image to grayscale using the conventional averaging algorithm.
1831
+ *
1832
+ * # Arguments
1833
+ * * `photon_image` - A PhotonImage.
1834
+ * # Example
1835
+ *
1836
+ * ```no_run
1837
+ * // For example, to convert an image of type `PhotonImage` to grayscale:
1838
+ * use photon_rs::monochrome::grayscale;
1839
+ * use photon_rs::native::open_image;
1840
+ *
1841
+ * let mut img = open_image("img.jpg").expect("File should open");
1842
+ * grayscale(&mut img);
1843
+ * ```
1844
+ * @param {PhotonImage} img
1845
+ */
1846
+ export function grayscale(img) {
1847
+ _assertClass(img, PhotonImage);
1848
+ wasm.grayscale(img.__wbg_ptr);
1849
+ }
1850
+
1851
+ /**
1852
+ * Convert an image to grayscale with a human corrected factor, to account for human vision.
1853
+ *
1854
+ * # Arguments
1855
+ * * `photon_image` - A PhotonImage.
1856
+ * # Example
1857
+ *
1858
+ * ```no_run
1859
+ * // For example, to convert an image of type `PhotonImage` to grayscale with a human corrected factor:
1860
+ * use photon_rs::monochrome::grayscale_human_corrected;
1861
+ * use photon_rs::native::open_image;
1862
+ *
1863
+ * let mut img = open_image("img.jpg").expect("File should open");
1864
+ * grayscale_human_corrected(&mut img);
1865
+ * ```
1866
+ * @param {PhotonImage} img
1867
+ */
1868
+ export function grayscale_human_corrected(img) {
1869
+ _assertClass(img, PhotonImage);
1870
+ wasm.grayscale_human_corrected(img.__wbg_ptr);
1871
+ }
1872
+
1873
+ /**
1874
+ * Employ only a limited number of gray shades in an image.
1875
+ *
1876
+ * # Arguments
1877
+ * * `photon_image` - A PhotonImage.
1878
+ * * `num_shades` - The number of grayscale shades to be displayed in the image.
1879
+ *
1880
+ * # Example
1881
+ *
1882
+ * ```no_run
1883
+ * // For example, to limit an image to four shades of gray only:
1884
+ * use photon_rs::monochrome::grayscale_shades;
1885
+ * use photon_rs::native::open_image;
1886
+ *
1887
+ * let mut img = open_image("img.jpg").expect("File should open");
1888
+ * grayscale_shades(&mut img, 4_u8);
1889
+ * ```
1890
+ * @param {PhotonImage} photon_image
1891
+ * @param {number} num_shades
1892
+ */
1893
+ export function grayscale_shades(photon_image, num_shades) {
1894
+ _assertClass(photon_image, PhotonImage);
1895
+ wasm.grayscale_shades(photon_image.__wbg_ptr, num_shades);
1896
+ }
1897
+
1898
+ /**
1899
+ * Halftoning effect.
1900
+ *
1901
+ * # Arguments
1902
+ * * `img` - A PhotonImage that contains a view into the image.
1903
+ * # Example
1904
+ *
1905
+ * ```no_run
1906
+ * // For example:
1907
+ * use photon_rs::effects::halftone;
1908
+ * use photon_rs::native::open_image;
1909
+ *
1910
+ * let mut img = open_image("img.jpg").expect("File should open");
1911
+ * halftone(&mut img);
1912
+ * ```
1913
+ * @param {PhotonImage} photon_image
1914
+ */
1915
+ export function halftone(photon_image) {
1916
+ _assertClass(photon_image, PhotonImage);
1917
+ wasm.halftone(photon_image.__wbg_ptr);
1918
+ }
1919
+
1920
+ /**
1921
+ * Horizontal strips. Divide an image into a series of equal-height strips, for an artistic effect.
1922
+ *
1923
+ * # Arguments
1924
+ * * `img` - A PhotonImage that contains a view into the image.
1925
+ * * `num_strips` - The number of strips
1926
+ * # Example
1927
+ *
1928
+ * ```no_run
1929
+ * // For example, to draw horizontal strips on a `PhotonImage`:
1930
+ * use photon_rs::effects::horizontal_strips;
1931
+ * use photon_rs::native::open_image;
1932
+ *
1933
+ * let mut img = open_image("img.jpg").expect("File should open");
1934
+ * horizontal_strips(&mut img, 8u8);
1935
+ * ```
1936
+ * @param {PhotonImage} photon_image
1937
+ * @param {number} num_strips
1938
+ */
1939
+ export function horizontal_strips(photon_image, num_strips) {
1940
+ _assertClass(photon_image, PhotonImage);
1941
+ wasm.horizontal_strips(photon_image.__wbg_ptr, num_strips);
1942
+ }
1943
+
1944
+ /**
1945
+ * Image manipulation effects in the HSL colour space.
1946
+ *
1947
+ * Effects include:
1948
+ * * **saturate** - Saturation increase.
1949
+ * * **desaturate** - Desaturate the image.
1950
+ * * **shift_hue** - Hue rotation by a specified number of degrees.
1951
+ * * **darken** - Decrease the brightness.
1952
+ * * **lighten** - Increase the brightness.
1953
+ *
1954
+ * # Arguments
1955
+ * * `photon_image` - A PhotonImage.
1956
+ * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten`
1957
+ * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by.
1958
+ * # Example
1959
+ * ```no_run
1960
+ * // For example to increase the saturation by 10%:
1961
+ * use photon_rs::colour_spaces::hsl;
1962
+ * use photon_rs::native::open_image;
1963
+ *
1964
+ * // Open the image. A PhotonImage is returned.
1965
+ * let mut img = open_image("img.jpg").expect("File should open");
1966
+ * hsl(&mut img, "saturate", 0.1_f32);
1967
+ * ```
1968
+ * @param {PhotonImage} photon_image
1969
+ * @param {string} mode
1970
+ * @param {number} amt
1971
+ */
1972
+ export function hsl(photon_image, mode, amt) {
1973
+ _assertClass(photon_image, PhotonImage);
1974
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1975
+ const len0 = WASM_VECTOR_LEN;
1976
+ wasm.hsl(photon_image.__wbg_ptr, ptr0, len0, amt);
1977
+ }
1978
+
1979
+ /**
1980
+ * Image manipulation effects in the HSLuv colour space
1981
+ *
1982
+ * Effects include:
1983
+ * * **saturate** - Saturation increase.
1984
+ * * **desaturate** - Desaturate the image.
1985
+ * * **shift_hue** - Hue rotation by a specified number of degrees.
1986
+ * * **darken** - Decrease the brightness.
1987
+ * * **lighten** - Increase the brightness.
1988
+ *
1989
+ * # Arguments
1990
+ * * `photon_image` - A PhotonImage.
1991
+ * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten`
1992
+ * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by.
1993
+ * # Example
1994
+ * ```no_run
1995
+ * // For example to increase the saturation by 10%:
1996
+ * use photon_rs::colour_spaces::hsluv;
1997
+ * use photon_rs::native::open_image;
1998
+ *
1999
+ * // Open the image. A PhotonImage is returned.
2000
+ * let mut img = open_image("img.jpg").expect("File should open");
2001
+ * hsluv(&mut img, "saturate", 0.1_f32);
2002
+ * ```
2003
+ * @param {PhotonImage} photon_image
2004
+ * @param {string} mode
2005
+ * @param {number} amt
2006
+ */
2007
+ export function hsluv(photon_image, mode, amt) {
2008
+ _assertClass(photon_image, PhotonImage);
2009
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2010
+ const len0 = WASM_VECTOR_LEN;
2011
+ wasm.hsluv(photon_image.__wbg_ptr, ptr0, len0, amt);
2012
+ }
2013
+
2014
+ /**
2015
+ * Image manipulation in the HSV colour space.
2016
+ *
2017
+ * Effects include:
2018
+ * * **saturate** - Saturation increase.
2019
+ * * **desaturate** - Desaturate the image.
2020
+ * * **shift_hue** - Hue rotation by a specified number of degrees.
2021
+ * * **darken** - Decrease the brightness.
2022
+ * * **lighten** - Increase the brightness.
2023
+ *
2024
+ * # Arguments
2025
+ * * `photon_image` - A PhotonImage.
2026
+ * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten`
2027
+ * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by.
2028
+ *
2029
+ * # Example
2030
+ * ```no_run
2031
+ * // For example to increase the saturation by 10%:
2032
+ * use photon_rs::colour_spaces::hsv;
2033
+ * use photon_rs::native::open_image;
2034
+ *
2035
+ * // Open the image. A PhotonImage is returned.
2036
+ * let mut img = open_image("img.jpg").expect("File should open");
2037
+ * hsv(&mut img, "saturate", 0.1_f32);
2038
+ * ```
2039
+ * @param {PhotonImage} photon_image
2040
+ * @param {string} mode
2041
+ * @param {number} amt
2042
+ */
2043
+ export function hsv(photon_image, mode, amt) {
2044
+ _assertClass(photon_image, PhotonImage);
2045
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2046
+ const len0 = WASM_VECTOR_LEN;
2047
+ wasm.hsv(photon_image.__wbg_ptr, ptr0, len0, amt);
2048
+ }
2049
+
2050
+ /**
2051
+ * Shift hue by a specified number of degrees in the HSL colour space.
2052
+ * # Arguments
2053
+ * * `img` - A PhotonImage.
2054
+ * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by.
2055
+ *
2056
+ * # Example
2057
+ * ```no_run
2058
+ * // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space:
2059
+ * use photon_rs::colour_spaces::hue_rotate_hsl;
2060
+ * use photon_rs::native::open_image;
2061
+ *
2062
+ * // Open the image. A PhotonImage is returned.
2063
+ * let mut img = open_image("img.jpg").expect("File should open");
2064
+ * hue_rotate_hsl(&mut img, 120_f32);
2065
+ * ```
2066
+ * @param {PhotonImage} img
2067
+ * @param {number} degrees
2068
+ */
2069
+ export function hue_rotate_hsl(img, degrees) {
2070
+ _assertClass(img, PhotonImage);
2071
+ wasm.hue_rotate_hsl(img.__wbg_ptr, degrees);
2072
+ }
2073
+
2074
+ /**
2075
+ * Shift hue by a specified number of degrees in the HSLuv colour space.
2076
+ * # Arguments
2077
+ * * `img` - A PhotonImage.
2078
+ * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by.
2079
+ *
2080
+ * # Example
2081
+ * ```no_run
2082
+ * // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space:
2083
+ * use photon_rs::colour_spaces::hue_rotate_hsluv;
2084
+ * use photon_rs::native::open_image;
2085
+ *
2086
+ * // Open the image. A PhotonImage is returned.
2087
+ * let mut img = open_image("img.jpg").expect("File should open");
2088
+ * hue_rotate_hsluv(&mut img, 120_f32);
2089
+ * ```
2090
+ * @param {PhotonImage} img
2091
+ * @param {number} degrees
2092
+ */
2093
+ export function hue_rotate_hsluv(img, degrees) {
2094
+ _assertClass(img, PhotonImage);
2095
+ wasm.hue_rotate_hsluv(img.__wbg_ptr, degrees);
2096
+ }
2097
+
2098
+ /**
2099
+ * Shift hue by a specified number of degrees in the HSV colour space.
2100
+ * # Arguments
2101
+ * * `img` - A PhotonImage.
2102
+ * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by.
2103
+ *
2104
+ * # Example
2105
+ * ```no_run
2106
+ * // For example to hue rotate/shift the hue by 120 degrees in the HSV colour space:
2107
+ * use photon_rs::colour_spaces::hue_rotate_hsv;
2108
+ * use photon_rs::native::open_image;
2109
+ *
2110
+ * // Open the image. A PhotonImage is returned.
2111
+ * let mut img = open_image("img.jpg").expect("File should open");
2112
+ * hue_rotate_hsv(&mut img, 120_f32);
2113
+ * ```
2114
+ * @param {PhotonImage} img
2115
+ * @param {number} degrees
2116
+ */
2117
+ export function hue_rotate_hsv(img, degrees) {
2118
+ _assertClass(img, PhotonImage);
2119
+ wasm.hue_rotate_hsv(img.__wbg_ptr, degrees);
2120
+ }
2121
+
2122
+ /**
2123
+ * Shift hue by a specified number of degrees in the LCh colour space.
2124
+ * # Arguments
2125
+ * * `img` - A PhotonImage.
2126
+ * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by.
2127
+ *
2128
+ * # Example
2129
+ * ```no_run
2130
+ * // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space:
2131
+ * use photon_rs::colour_spaces::hue_rotate_lch;
2132
+ * use photon_rs::native::open_image;
2133
+ *
2134
+ * // Open the image. A PhotonImage is returned.
2135
+ * let mut img = open_image("img.jpg").expect("File should open");
2136
+ * hue_rotate_lch(&mut img, 120_f32);
2137
+ * ```
2138
+ * @param {PhotonImage} img
2139
+ * @param {number} degrees
2140
+ */
2141
+ export function hue_rotate_lch(img, degrees) {
2142
+ _assertClass(img, PhotonImage);
2143
+ wasm.hue_rotate_lch(img.__wbg_ptr, degrees);
2144
+ }
2145
+
2146
+ /**
2147
+ * Apply an identity kernel convolution to an image.
2148
+ *
2149
+ * # Arguments
2150
+ * * `img` -A PhotonImage.
2151
+ *
2152
+ * # Example
2153
+ *
2154
+ * ```no_run
2155
+ * // For example, to apply an identity kernel convolution:
2156
+ * use photon_rs::conv::identity;
2157
+ * use photon_rs::native::open_image;
2158
+ *
2159
+ * let mut img = open_image("img.jpg").expect("File should open");
2160
+ * identity(&mut img);
2161
+ * ```
2162
+ * @param {PhotonImage} photon_image
2163
+ */
2164
+ export function identity(photon_image) {
2165
+ _assertClass(photon_image, PhotonImage);
2166
+ wasm.identity(photon_image.__wbg_ptr);
2167
+ }
2168
+
2169
+ /**
2170
+ * Increase the brightness of an image by a constant.
2171
+ *
2172
+ * # Arguments
2173
+ * * `img` - A PhotonImage that contains a view into the image.
2174
+ * * `brightness` - A u8 to add to the brightness.
2175
+ * # Example
2176
+ *
2177
+ * ```no_run
2178
+ * use photon_rs::effects::inc_brightness;
2179
+ * use photon_rs::native::open_image;
2180
+ *
2181
+ * let mut img = open_image("img.jpg").expect("File should open");
2182
+ * inc_brightness(&mut img, 10_u8);
2183
+ * ```
2184
+ * @param {PhotonImage} photon_image
2185
+ * @param {number} brightness
2186
+ */
2187
+ export function inc_brightness(photon_image, brightness) {
2188
+ _assertClass(photon_image, PhotonImage);
2189
+ wasm.inc_brightness(photon_image.__wbg_ptr, brightness);
2190
+ }
2191
+
2192
+ /**
2193
+ * Invert RGB value of an image.
2194
+ *
2195
+ * # Arguments
2196
+ * * `photon_image` - A DynamicImage that contains a view into the image.
2197
+ * # Example
2198
+ *
2199
+ * ```no_run
2200
+ * use photon_rs::channels::invert;
2201
+ * use photon_rs::native::open_image;
2202
+ *
2203
+ * let mut img = open_image("img.jpg").expect("File should open");
2204
+ * invert(&mut img);
2205
+ * ```
2206
+ * @param {PhotonImage} photon_image
2207
+ */
2208
+ export function invert(photon_image) {
2209
+ _assertClass(photon_image, PhotonImage);
2210
+ wasm.invert(photon_image.__wbg_ptr);
2211
+ }
2212
+
2213
+ /**
2214
+ * Apply a standard laplace convolution.
2215
+ *
2216
+ * # Arguments
2217
+ * * `img` - A PhotonImage.
2218
+ *
2219
+ * # Example
2220
+ *
2221
+ * ```no_run
2222
+ * // For example, to apply a laplace effect:
2223
+ * use photon_rs::conv::laplace;
2224
+ * use photon_rs::native::open_image;
2225
+ *
2226
+ * let mut img = open_image("img.jpg").expect("File should open");
2227
+ * laplace(&mut img);
2228
+ * ```
2229
+ * @param {PhotonImage} photon_image
2230
+ */
2231
+ export function laplace(photon_image) {
2232
+ _assertClass(photon_image, PhotonImage);
2233
+ wasm.laplace(photon_image.__wbg_ptr);
2234
+ }
2235
+
2236
+ /**
2237
+ * Image manipulation effects in the LCh colour space
2238
+ *
2239
+ * Effects include:
2240
+ * * **saturate** - Saturation increase.
2241
+ * * **desaturate** - Desaturate the image.
2242
+ * * **shift_hue** - Hue rotation by a specified number of degrees.
2243
+ * * **darken** - Decrease the brightness.
2244
+ * * **lighten** - Increase the brightness.
2245
+ *
2246
+ * # Arguments
2247
+ * * `photon_image` - A PhotonImage.
2248
+ * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten`
2249
+ * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by.
2250
+ * # Example
2251
+ * ```no_run
2252
+ * // For example to increase the saturation by 10%:
2253
+ * use photon_rs::colour_spaces::lch;
2254
+ * use photon_rs::native::open_image;
2255
+ *
2256
+ * // Open the image. A PhotonImage is returned.
2257
+ * let mut img = open_image("img.jpg").expect("File should open");
2258
+ * lch(&mut img, "saturate", 0.1_f32);
2259
+ * ```
2260
+ * @param {PhotonImage} photon_image
2261
+ * @param {string} mode
2262
+ * @param {number} amt
2263
+ */
2264
+ export function lch(photon_image, mode, amt) {
2265
+ _assertClass(photon_image, PhotonImage);
2266
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2267
+ const len0 = WASM_VECTOR_LEN;
2268
+ wasm.lch(photon_image.__wbg_ptr, ptr0, len0, amt);
2269
+ }
2270
+
2271
+ /**
2272
+ * Lighten an image by a specified amount in the HSL colour space.
2273
+ * # Arguments
2274
+ * * `img` - A PhotonImage.
2275
+ * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by.
2276
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
2277
+ * Lightening by 80% would be represented by a `level` of 0.8
2278
+ *
2279
+ * # Example
2280
+ * ```no_run
2281
+ * // For example to lighten an image by 10% in the HSL colour space:
2282
+ * use photon_rs::colour_spaces::lighten_hsl;
2283
+ * use photon_rs::native::open_image;
2284
+ *
2285
+ * // Open the image. A PhotonImage is returned.
2286
+ * let mut img = open_image("img.jpg").expect("File should open");
2287
+ * lighten_hsl(&mut img, 0.1_f32);
2288
+ * ```
2289
+ * @param {PhotonImage} img
2290
+ * @param {number} level
2291
+ */
2292
+ export function lighten_hsl(img, level) {
2293
+ _assertClass(img, PhotonImage);
2294
+ wasm.lighten_hsl(img.__wbg_ptr, level);
2295
+ }
2296
+
2297
+ /**
2298
+ * Lighten an image by a specified amount in the HSLuv colour space.
2299
+ *
2300
+ * # Arguments
2301
+ * * `img` - A PhotonImage.
2302
+ * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by.
2303
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
2304
+ * Lightening by 80% would be represented by a `level` of 0.8
2305
+ *
2306
+ * # Example
2307
+ * ```no_run
2308
+ * // For example to lighten an image by 10% in the HSLuv colour space:
2309
+ * use photon_rs::colour_spaces::lighten_hsluv;
2310
+ * use photon_rs::native::open_image;
2311
+ *
2312
+ * // Open the image. A PhotonImage is returned.
2313
+ * let mut img = open_image("img.jpg").expect("File should open");
2314
+ * lighten_hsluv(&mut img, 0.1_f32);
2315
+ * ```
2316
+ * @param {PhotonImage} img
2317
+ * @param {number} level
2318
+ */
2319
+ export function lighten_hsluv(img, level) {
2320
+ _assertClass(img, PhotonImage);
2321
+ wasm.lighten_hsluv(img.__wbg_ptr, level);
2322
+ }
2323
+
2324
+ /**
2325
+ * Lighten an image by a specified amount in the HSV colour space.
2326
+ *
2327
+ * # Arguments
2328
+ * * `img` - A PhotonImage.
2329
+ * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by.
2330
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
2331
+ * Lightening by 80% would be represented by a `level` of 0.8
2332
+ *
2333
+ * # Example
2334
+ * ```no_run
2335
+ * // For example to lighten an image by 10% in the HSV colour space:
2336
+ * use photon_rs::colour_spaces::lighten_hsv;
2337
+ * use photon_rs::native::open_image;
2338
+ *
2339
+ * // Open the image. A PhotonImage is returned.
2340
+ * let mut img = open_image("img.jpg").expect("File should open");
2341
+ * lighten_hsv(&mut img, 0.1_f32);
2342
+ * ```
2343
+ * @param {PhotonImage} img
2344
+ * @param {number} level
2345
+ */
2346
+ export function lighten_hsv(img, level) {
2347
+ _assertClass(img, PhotonImage);
2348
+ wasm.lighten_hsv(img.__wbg_ptr, level);
2349
+ }
2350
+
2351
+ /**
2352
+ * Lighten an image by a specified amount in the LCh colour space.
2353
+ *
2354
+ * # Arguments
2355
+ * * `img` - A PhotonImage.
2356
+ * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by.
2357
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
2358
+ * Lightening by 80% would be represented by a `level` of 0.8
2359
+ *
2360
+ * # Example
2361
+ * ```no_run
2362
+ * // For example to lighten an image by 10% in the LCh colour space:
2363
+ * use photon_rs::colour_spaces::lighten_lch;
2364
+ * use photon_rs::native::open_image;
2365
+ *
2366
+ * // Open the image. A PhotonImage is returned.
2367
+ * let mut img = open_image("img.jpg").expect("File should open");
2368
+ * lighten_lch(&mut img, 0.1_f32);
2369
+ * ```
2370
+ * @param {PhotonImage} img
2371
+ * @param {number} level
2372
+ */
2373
+ export function lighten_lch(img, level) {
2374
+ _assertClass(img, PhotonImage);
2375
+ wasm.lighten_lch(img.__wbg_ptr, level);
2376
+ }
2377
+
2378
+ /**
2379
+ * Solarization on the Red and Green channels.
2380
+ *
2381
+ * # Arguments
2382
+ * * `img` - A PhotonImage.
2383
+ * # Example
2384
+ *
2385
+ * ```no_run
2386
+ * use photon_rs::filters::lix;
2387
+ * use photon_rs::native::open_image;
2388
+ *
2389
+ * let mut img = open_image("img.jpg").expect("File should open");
2390
+ * lix(&mut img);
2391
+ * ```
2392
+ * @param {PhotonImage} photon_image
2393
+ */
2394
+ export function lix(photon_image) {
2395
+ _assertClass(photon_image, PhotonImage);
2396
+ wasm.lix(photon_image.__wbg_ptr);
2397
+ }
2398
+
2399
+ /**
2400
+ * Apply a lofi effect to an image.
2401
+ *
2402
+ * # Arguments
2403
+ * * `img` - A PhotonImage.
2404
+ * # Example
2405
+ *
2406
+ * ```no_run
2407
+ * use photon_rs::filters::lofi;
2408
+ * use photon_rs::native::open_image;
2409
+ *
2410
+ * let mut img = open_image("img.jpg").expect("File should open");
2411
+ * lofi(&mut img);
2412
+ * ```
2413
+ * @param {PhotonImage} img
2414
+ */
2415
+ export function lofi(img) {
2416
+ _assertClass(img, PhotonImage);
2417
+ wasm.lofi(img.__wbg_ptr);
2418
+ }
2419
+
2420
+ /**
2421
+ * Mix image with a single color, supporting passing `opacity`.
2422
+ * The algorithm comes from Jimp. See `function mix` and `function colorFn` at following link:
2423
+ * https://github.com/oliver-moran/jimp/blob/29679faa597228ff2f20d34c5758e4d2257065a3/packages/plugin-color/src/index.js
2424
+ * Specifically, result_value = (mix_color_value - origin_value) * opacity + origin_value =
2425
+ * mix_color_value * opacity + (1 - opacity) * origin_value for each
2426
+ * of RGB channel.
2427
+ *
2428
+ * # Arguments
2429
+ * * `photon_image` - A PhotonImage that contains a view into the image.
2430
+ * * `mix_color` - the color to be mixed in, as an RGB value.
2431
+ * * `opacity` - the opacity of color when mixed to image. Float value from 0 to 1.
2432
+ * # Example
2433
+ *
2434
+ * ```no_run
2435
+ * // For example, to mix an image with rgb (50, 255, 254) and opacity 0.4:
2436
+ * use photon_rs::Rgb;
2437
+ * use photon_rs::colour_spaces::mix_with_colour;
2438
+ * use photon_rs::native::open_image;
2439
+ *
2440
+ * let mix_colour = Rgb::new(50_u8, 255_u8, 254_u8);
2441
+ * let mut img = open_image("img.jpg").expect("File should open");
2442
+ * mix_with_colour(&mut img, mix_colour, 0.4_f32);
2443
+ * ```
2444
+ * @param {PhotonImage} photon_image
2445
+ * @param {Rgb} mix_colour
2446
+ * @param {number} opacity
2447
+ */
2448
+ export function mix_with_colour(photon_image, mix_colour, opacity) {
2449
+ _assertClass(photon_image, PhotonImage);
2450
+ _assertClass(mix_colour, Rgb);
2451
+ var ptr0 = mix_colour.__destroy_into_raw();
2452
+ wasm.mix_with_colour(photon_image.__wbg_ptr, ptr0, opacity);
2453
+ }
2454
+
2455
+ /**
2456
+ * Apply a monochrome effect of a certain colour.
2457
+ *
2458
+ * It does so by averaging the R, G, and B values of a pixel, and then adding a
2459
+ * separate value to that averaged value for each channel to produce a tint.
2460
+ * # Arguments
2461
+ * * `photon_image` - A PhotonImage.
2462
+ * * `r_offset` - The value to add to the Red channel per pixel.
2463
+ * * `g_offset` - The value to add to the Green channel per pixel.
2464
+ * * `b_offset` - The value to add to the Blue channel per pixel.
2465
+ *
2466
+ * # Example
2467
+ *
2468
+ * ```no_run
2469
+ * // For example, to apply a monochrome effect to an image:
2470
+ * use photon_rs::monochrome::monochrome;
2471
+ * use photon_rs::native::open_image;
2472
+ *
2473
+ * let mut img = open_image("img.jpg").expect("File should open");
2474
+ * monochrome(&mut img, 40_u32, 50_u32, 100_u32);
2475
+ * ```
2476
+ * @param {PhotonImage} img
2477
+ * @param {number} r_offset
2478
+ * @param {number} g_offset
2479
+ * @param {number} b_offset
2480
+ */
2481
+ export function monochrome(img, r_offset, g_offset, b_offset) {
2482
+ _assertClass(img, PhotonImage);
2483
+ wasm.monochrome(img.__wbg_ptr, r_offset, g_offset, b_offset);
2484
+ }
2485
+
2486
+ /**
2487
+ * Monochrome tint effect with increased contrast
2488
+ *
2489
+ * # Arguments
2490
+ * * `img` - A PhotonImage.
2491
+ * * `rgb_color` - RGB color
2492
+ * # Example
2493
+ *
2494
+ * ```no_run
2495
+ * use photon_rs::filters::monochrome_tint;
2496
+ * use photon_rs::native::open_image;
2497
+ * use photon_rs::Rgb;
2498
+ *
2499
+ * let mut img = open_image("img.jpg").expect("File should open");
2500
+ * let rgb_color = Rgb::new(12, 12, 10);
2501
+ * monochrome_tint(&mut img, rgb_color);
2502
+ * ```
2503
+ * @param {PhotonImage} img
2504
+ * @param {Rgb} rgb_color
2505
+ */
2506
+ export function monochrome_tint(img, rgb_color) {
2507
+ _assertClass(img, PhotonImage);
2508
+ _assertClass(rgb_color, Rgb);
2509
+ var ptr0 = rgb_color.__destroy_into_raw();
2510
+ wasm.monochrome_tint(img.__wbg_ptr, ptr0);
2511
+ }
2512
+
2513
+ /**
2514
+ * Adds multiple offsets to the image by a certain number of pixels (on two channels).
2515
+ *
2516
+ * # Arguments
2517
+ * * `img` - A PhotonImage that contains a view into the image.
2518
+ * * `offset` - The offset is added to the pixels in the image.
2519
+ * # Example
2520
+ *
2521
+ * ```no_run
2522
+ * // For example, to add a 30-pixel offset to both the red and blue channels:
2523
+ * use photon_rs::effects::multiple_offsets;
2524
+ * use photon_rs::native::open_image;
2525
+ *
2526
+ * let mut img = open_image("img.jpg").expect("File should open");
2527
+ * multiple_offsets(&mut img, 30_u32, 0_usize, 2_usize);
2528
+ * ```
2529
+ * @param {PhotonImage} photon_image
2530
+ * @param {number} offset
2531
+ * @param {number} channel_index
2532
+ * @param {number} channel_index2
2533
+ */
2534
+ export function multiple_offsets(photon_image, offset, channel_index, channel_index2) {
2535
+ _assertClass(photon_image, PhotonImage);
2536
+ wasm.multiple_offsets(photon_image.__wbg_ptr, offset, channel_index, channel_index2);
2537
+ }
2538
+
2539
+ /**
2540
+ * Solarization on the Blue channel.
2541
+ *
2542
+ * # Arguments
2543
+ * * `img` - A PhotonImage.
2544
+ * # Example
2545
+ *
2546
+ * ```no_run
2547
+ * use photon_rs::filters::neue;
2548
+ * use photon_rs::native::open_image;
2549
+ *
2550
+ * let mut img = open_image("img.jpg").expect("File should open");
2551
+ * neue(&mut img);
2552
+ * ```
2553
+ * @param {PhotonImage} photon_image
2554
+ */
2555
+ export function neue(photon_image) {
2556
+ _assertClass(photon_image, PhotonImage);
2557
+ wasm.neue(photon_image.__wbg_ptr);
2558
+ }
2559
+
2560
+ /**
2561
+ * Noise reduction.
2562
+ *
2563
+ * # Arguments
2564
+ * * `img` - A PhotonImage.
2565
+ *
2566
+ * # Example
2567
+ *
2568
+ * ```no_run
2569
+ * // For example, to noise reduct an image:
2570
+ * use photon_rs::conv::noise_reduction;
2571
+ * use photon_rs::native::open_image;
2572
+ *
2573
+ * let mut img = open_image("img.jpg").expect("File should open");
2574
+ * noise_reduction(&mut img);
2575
+ * ```
2576
+ * Adds a constant to a select R, G, or B channel's value.
2577
+ * @param {PhotonImage} photon_image
2578
+ */
2579
+ export function noise_reduction(photon_image) {
2580
+ _assertClass(photon_image, PhotonImage);
2581
+ wasm.noise_reduction(photon_image.__wbg_ptr);
2582
+ }
2583
+
2584
+ /**
2585
+ * Normalizes an image by remapping its range of pixels values. Only RGB
2586
+ * channels are processed and each channel is stretched to \[0, 255\] range
2587
+ * independently. This process is also known as contrast stretching.
2588
+ * # Arguments
2589
+ * * `photon_image` - A PhotonImage that contains a view into the image.
2590
+ * # Example
2591
+ *
2592
+ * ```no_run
2593
+ * // For example, to turn an image of type `PhotonImage` into a normalized image:
2594
+ * use photon_rs::effects::normalize;
2595
+ * use photon_rs::native::open_image;
2596
+ *
2597
+ * let mut img = open_image("img.jpg").expect("File should open");
2598
+ * normalize(&mut img);
2599
+ * ```
2600
+ * @param {PhotonImage} photon_image
2601
+ */
2602
+ export function normalize(photon_image) {
2603
+ _assertClass(photon_image, PhotonImage);
2604
+ wasm.normalize(photon_image.__wbg_ptr);
2605
+ }
2606
+
2607
+ /**
2608
+ * Apply a greyscale effect with increased contrast.
2609
+ *
2610
+ * # Arguments
2611
+ * * `img` - A PhotonImage.
2612
+ * # Example
2613
+ *
2614
+ * ```no_run
2615
+ * use photon_rs::filters::obsidian;
2616
+ * use photon_rs::native::open_image;
2617
+ *
2618
+ * let mut img = open_image("img.jpg").expect("File should open");
2619
+ * obsidian(&mut img);
2620
+ * ```
2621
+ * @param {PhotonImage} img
2622
+ */
2623
+ export function obsidian(img) {
2624
+ _assertClass(img, PhotonImage);
2625
+ wasm.obsidian(img.__wbg_ptr);
2626
+ }
2627
+
2628
+ /**
2629
+ * Adds an offset to the image by a certain number of pixels.
2630
+ *
2631
+ * This creates an RGB shift effect.
2632
+ *
2633
+ * # Arguments
2634
+ * * `img` - A PhotonImage that contains a view into the image.
2635
+ * * `channel_index`: The index of the channel to increment. 0 for red, 1 for green and 2 for blue.
2636
+ * * `offset` - The offset is added to the pixels in the image.
2637
+ * # Example
2638
+ *
2639
+ * ```no_run
2640
+ * // For example, to offset pixels by 30 pixels on the red channel:
2641
+ * use photon_rs::effects::offset;
2642
+ * use photon_rs::native::open_image;
2643
+ *
2644
+ * let mut img = open_image("img.jpg").expect("File should open");
2645
+ * offset(&mut img, 0_usize, 30_u32);
2646
+ * ```
2647
+ * @param {PhotonImage} photon_image
2648
+ * @param {number} channel_index
2649
+ * @param {number} offset
2650
+ */
2651
+ export function offset(photon_image, channel_index, offset) {
2652
+ _assertClass(photon_image, PhotonImage);
2653
+ wasm.offset(photon_image.__wbg_ptr, channel_index, offset);
2654
+ }
2655
+
2656
+ /**
2657
+ * Adds an offset to the blue channel by a certain number of pixels.
2658
+ *
2659
+ * # Arguments
2660
+ * * `img` - A PhotonImage that contains a view into the image.
2661
+ * * `offset_amt` - The offset you want to move the blue channel by.
2662
+ * # Example
2663
+ * // For example, to add an offset to the green channel by 40 pixels.
2664
+ *
2665
+ * ```no_run
2666
+ * use photon_rs::effects::offset_blue;
2667
+ * use photon_rs::native::open_image;
2668
+ *
2669
+ * let mut img = open_image("img.jpg").expect("File should open");
2670
+ * offset_blue(&mut img, 40_u32);
2671
+ * ```
2672
+ * @param {PhotonImage} img
2673
+ * @param {number} offset_amt
2674
+ */
2675
+ export function offset_blue(img, offset_amt) {
2676
+ _assertClass(img, PhotonImage);
2677
+ wasm.offset_blue(img.__wbg_ptr, offset_amt);
2678
+ }
2679
+
2680
+ /**
2681
+ * Adds an offset to the green channel by a certain number of pixels.
2682
+ *
2683
+ * # Arguments
2684
+ * * `img` - A PhotonImage that contains a view into the image.
2685
+ * * `offset` - The offset you want to move the green channel by.
2686
+ * # Example
2687
+ *
2688
+ * ```no_run
2689
+ * // For example, to add an offset to the green channel by 30 pixels.
2690
+ * use photon_rs::effects::offset_green;
2691
+ * use photon_rs::native::open_image;
2692
+ *
2693
+ * let mut img = open_image("img.jpg").expect("File should open");
2694
+ * offset_green(&mut img, 30_u32);
2695
+ * ```
2696
+ * @param {PhotonImage} img
2697
+ * @param {number} offset_amt
2698
+ */
2699
+ export function offset_green(img, offset_amt) {
2700
+ _assertClass(img, PhotonImage);
2701
+ wasm.offset_green(img.__wbg_ptr, offset_amt);
2702
+ }
2703
+
2704
+ /**
2705
+ * Adds an offset to the red channel by a certain number of pixels.
2706
+ *
2707
+ * # Arguments
2708
+ * * `img` - A PhotonImage that contains a view into the image.
2709
+ * * `offset` - The offset you want to move the red channel by.
2710
+ * # Example
2711
+ *
2712
+ * ```no_run
2713
+ * // For example, to add an offset to the red channel by 30 pixels.
2714
+ * use photon_rs::effects::offset_red;
2715
+ * use photon_rs::native::open_image;
2716
+ *
2717
+ * let mut img = open_image("img.jpg").expect("File should open");
2718
+ * offset_red(&mut img, 30_u32);
2719
+ * ```
2720
+ * @param {PhotonImage} img
2721
+ * @param {number} offset_amt
2722
+ */
2723
+ export function offset_red(img, offset_amt) {
2724
+ _assertClass(img, PhotonImage);
2725
+ wasm.offset_red(img.__wbg_ptr, offset_amt);
2726
+ }
2727
+
2728
+ /**
2729
+ * Turn an image into an oil painting
2730
+ *
2731
+ * # Arguments
2732
+ * * `img` - A PhotonImage that contains a view into the image.
2733
+ * * `radius` - Radius of each paint particle
2734
+ * * `intesnity` - How artsy an Image should be
2735
+ * # Example
2736
+ *
2737
+ * ```no_run
2738
+ * // For example, to oil an image of type `PhotonImage`:
2739
+ * use photon_rs::effects::oil;
2740
+ * use photon_rs::native::open_image;
2741
+ *
2742
+ * let mut img = open_image("img.jpg").expect("File should open");
2743
+ * oil(&mut img, 4i32, 55.0);
2744
+ * ```
2745
+ * @param {PhotonImage} photon_image
2746
+ * @param {number} radius
2747
+ * @param {number} intensity
2748
+ */
2749
+ export function oil(photon_image, radius, intensity) {
2750
+ _assertClass(photon_image, PhotonImage);
2751
+ wasm.oil(photon_image.__wbg_ptr, radius, intensity);
2752
+ }
2753
+
2754
+ /**
2755
+ * Convert a HTML5 Canvas Element to a PhotonImage.
2756
+ *
2757
+ * This converts the ImageData found in the canvas context to a PhotonImage,
2758
+ * which can then have effects or filters applied to it.
2759
+ * @param {HTMLCanvasElement} canvas
2760
+ * @param {CanvasRenderingContext2D} ctx
2761
+ * @returns {PhotonImage}
2762
+ */
2763
+ export function open_image(canvas, ctx) {
2764
+ const ret = wasm.open_image(canvas, ctx);
2765
+ return PhotonImage.__wrap(ret);
2766
+ }
2767
+
2768
+ /**
2769
+ * Apply padding on the left side of the PhotonImage
2770
+ * A padded PhotonImage is returned.
2771
+ * # Arguments
2772
+ * * `img` - A PhotonImage. See the PhotonImage struct for details.
2773
+ * * `padding` - The amount of padding to be applied to the PhotonImage.
2774
+ * * `padding_rgba` - Tuple containing the RGBA code for padding color.
2775
+ *
2776
+ * # Example
2777
+ *
2778
+ * ```no_run
2779
+ * // For example, to apply a padding of 10 pixels on the bottom of a PhotonImage:
2780
+ * use photon_rs::transform::padding_bottom;
2781
+ * use photon_rs::native::open_image;
2782
+ * use photon_rs::Rgba;
2783
+ *
2784
+ * let mut img = open_image("img.jpg").expect("File should open");
2785
+ * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8);
2786
+ * padding_bottom(&img, 10_u32, rgba);
2787
+ * ```
2788
+ * @param {PhotonImage} img
2789
+ * @param {number} padding
2790
+ * @param {Rgba} padding_rgba
2791
+ * @returns {PhotonImage}
2792
+ */
2793
+ export function padding_bottom(img, padding, padding_rgba) {
2794
+ _assertClass(img, PhotonImage);
2795
+ _assertClass(padding_rgba, Rgba);
2796
+ var ptr0 = padding_rgba.__destroy_into_raw();
2797
+ const ret = wasm.padding_bottom(img.__wbg_ptr, padding, ptr0);
2798
+ return PhotonImage.__wrap(ret);
2799
+ }
2800
+
2801
+ /**
2802
+ * Apply padding on the left side of the PhotonImage
2803
+ * A padded PhotonImage is returned.
2804
+ * # Arguments
2805
+ * * `img` - A PhotonImage. See the PhotonImage struct for details.
2806
+ * * `padding` - The amount of padding to be applied to the PhotonImage.
2807
+ * * `padding_rgba` - Tuple containing the RGBA code for padding color.
2808
+ *
2809
+ * # Example
2810
+ *
2811
+ * ```no_run
2812
+ * // For example, to apply a padding of 10 pixels on the left side of a PhotonImage:
2813
+ * use photon_rs::transform::padding_left;
2814
+ * use photon_rs::native::open_image;
2815
+ * use photon_rs::Rgba;
2816
+ *
2817
+ * let mut img = open_image("img.jpg").expect("File should open");
2818
+ * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8);
2819
+ * padding_left(&img, 10_u32, rgba);
2820
+ * ```
2821
+ * @param {PhotonImage} img
2822
+ * @param {number} padding
2823
+ * @param {Rgba} padding_rgba
2824
+ * @returns {PhotonImage}
2825
+ */
2826
+ export function padding_left(img, padding, padding_rgba) {
2827
+ _assertClass(img, PhotonImage);
2828
+ _assertClass(padding_rgba, Rgba);
2829
+ var ptr0 = padding_rgba.__destroy_into_raw();
2830
+ const ret = wasm.padding_left(img.__wbg_ptr, padding, ptr0);
2831
+ return PhotonImage.__wrap(ret);
2832
+ }
2833
+
2834
+ /**
2835
+ * Apply padding on the left side of the PhotonImage
2836
+ * A padded PhotonImage is returned.
2837
+ * # Arguments
2838
+ * * `img` - A PhotonImage. See the PhotonImage struct for details.
2839
+ * * `padding` - The amount of padding to be applied to the PhotonImage.
2840
+ * * `padding_rgba` - Tuple containing the RGBA code for padding color.
2841
+ *
2842
+ * # Example
2843
+ *
2844
+ * ```no_run
2845
+ * // For example, to apply a padding of 10 pixels on the right side of a PhotonImage:
2846
+ * use photon_rs::transform::padding_right;
2847
+ * use photon_rs::native::open_image;
2848
+ * use photon_rs::Rgba;
2849
+ *
2850
+ * let mut img = open_image("img.jpg").expect("File should open");
2851
+ * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8);
2852
+ * padding_right(&img, 10_u32, rgba);
2853
+ * ```
2854
+ * @param {PhotonImage} img
2855
+ * @param {number} padding
2856
+ * @param {Rgba} padding_rgba
2857
+ * @returns {PhotonImage}
2858
+ */
2859
+ export function padding_right(img, padding, padding_rgba) {
2860
+ _assertClass(img, PhotonImage);
2861
+ _assertClass(padding_rgba, Rgba);
2862
+ var ptr0 = padding_rgba.__destroy_into_raw();
2863
+ const ret = wasm.padding_right(img.__wbg_ptr, padding, ptr0);
2864
+ return PhotonImage.__wrap(ret);
2865
+ }
2866
+
2867
+ /**
2868
+ * Apply padding on the left side of the PhotonImage
2869
+ * A padded PhotonImage is returned.
2870
+ * # Arguments
2871
+ * * `img` - A PhotonImage. See the PhotonImage struct for details.
2872
+ * * `padding` - The amount of padding to be applied to the PhotonImage.
2873
+ * * `padding_rgba` - Tuple containing the RGBA code for padding color.
2874
+ *
2875
+ * # Example
2876
+ *
2877
+ * ```no_run
2878
+ * // For example, to apply a padding of 10 pixels on the top of a PhotonImage:
2879
+ * use photon_rs::transform::padding_top;
2880
+ * use photon_rs::native::open_image;
2881
+ * use photon_rs::Rgba;
2882
+ *
2883
+ * let mut img = open_image("img.jpg").expect("File should open");
2884
+ * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8);
2885
+ * padding_top(&img, 10_u32, rgba);
2886
+ * ```
2887
+ * @param {PhotonImage} img
2888
+ * @param {number} padding
2889
+ * @param {Rgba} padding_rgba
2890
+ * @returns {PhotonImage}
2891
+ */
2892
+ export function padding_top(img, padding, padding_rgba) {
2893
+ _assertClass(img, PhotonImage);
2894
+ _assertClass(padding_rgba, Rgba);
2895
+ var ptr0 = padding_rgba.__destroy_into_raw();
2896
+ const ret = wasm.padding_top(img.__wbg_ptr, padding, ptr0);
2897
+ return PhotonImage.__wrap(ret);
2898
+ }
2899
+
2900
+ /**
2901
+ * Apply uniform padding around the PhotonImage
2902
+ * A padded PhotonImage is returned.
2903
+ * # Arguments
2904
+ * * `img` - A PhotonImage. See the PhotonImage struct for details.
2905
+ * * `padding` - The amount of padding to be applied to the PhotonImage.
2906
+ * * `padding_rgba` - Tuple containing the RGBA code for padding color.
2907
+ *
2908
+ * # Example
2909
+ *
2910
+ * ```no_run
2911
+ * // For example, to apply a padding of 10 pixels around a PhotonImage:
2912
+ * use photon_rs::transform::padding_uniform;
2913
+ * use photon_rs::native::open_image;
2914
+ * use photon_rs::Rgba;
2915
+ *
2916
+ * let mut img = open_image("img.jpg").expect("File should open");
2917
+ * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8);
2918
+ * padding_uniform(&img, 10_u32, rgba);
2919
+ * ```
2920
+ * @param {PhotonImage} img
2921
+ * @param {number} padding
2922
+ * @param {Rgba} padding_rgba
2923
+ * @returns {PhotonImage}
2924
+ */
2925
+ export function padding_uniform(img, padding, padding_rgba) {
2926
+ _assertClass(img, PhotonImage);
2927
+ _assertClass(padding_rgba, Rgba);
2928
+ var ptr0 = padding_rgba.__destroy_into_raw();
2929
+ const ret = wasm.padding_uniform(img.__wbg_ptr, padding, ptr0);
2930
+ return PhotonImage.__wrap(ret);
2931
+ }
2932
+
2933
+ /**
2934
+ * Apply a rose tint to an image.
2935
+ *
2936
+ * # Arguments
2937
+ * * `img` - A PhotonImage.
2938
+ * # Example
2939
+ *
2940
+ * ```no_run
2941
+ * use photon_rs::filters::pastel_pink;
2942
+ * use photon_rs::native::open_image;
2943
+ *
2944
+ * let mut img = open_image("img.jpg").expect("File should open");
2945
+ * pastel_pink(&mut img);
2946
+ * ```
2947
+ * @param {PhotonImage} img
2948
+ */
2949
+ export function pastel_pink(img) {
2950
+ _assertClass(img, PhotonImage);
2951
+ wasm.pastel_pink(img.__wbg_ptr);
2952
+ }
2953
+
2954
+ /**
2955
+ * Add pink-tinted noise to an image.
2956
+ *
2957
+ * **[WASM SUPPORT IS AVAILABLE]**: Randomized thread pools cannot be created with WASM, but
2958
+ * a workaround using js_sys::Math::random works now.
2959
+ * # Arguments
2960
+ * * `name` - A PhotonImage that contains a view into the image.
2961
+ *
2962
+ * # Example
2963
+ *
2964
+ * ```no_run
2965
+ * // For example, to add pink-tinted noise to an image:
2966
+ * use photon_rs::native::open_image;
2967
+ * use photon_rs::noise::pink_noise;
2968
+ *
2969
+ * let mut img = open_image("img.jpg").expect("File should open");
2970
+ * pink_noise(&mut img);
2971
+ * ```
2972
+ * @param {PhotonImage} photon_image
2973
+ */
2974
+ export function pink_noise(photon_image) {
2975
+ _assertClass(photon_image, PhotonImage);
2976
+ wasm.pink_noise(photon_image.__wbg_ptr);
2977
+ }
2978
+
2979
+ /**
2980
+ * Pixelize an image.
2981
+ *
2982
+ * # Arguments
2983
+ * * `photon_image` - A PhotonImage that contains a view into the image.
2984
+ * * `pixel_size` - Targeted pixel size of generated image.
2985
+ * # Example
2986
+ *
2987
+ * ```no_run
2988
+ * // For example, to turn an image of type `PhotonImage` into a pixelized image with 50 pixels blocks:
2989
+ * use photon_rs::effects::pixelize;
2990
+ * use photon_rs::native::open_image;
2991
+ *
2992
+ * let mut img = open_image("img.jpg").expect("File should open");
2993
+ * pixelize(&mut img, 50);
2994
+ * ```
2995
+ * @param {PhotonImage} photon_image
2996
+ * @param {number} pixel_size
2997
+ */
2998
+ export function pixelize(photon_image, pixel_size) {
2999
+ _assertClass(photon_image, PhotonImage);
3000
+ wasm.pixelize(photon_image.__wbg_ptr, pixel_size);
3001
+ }
3002
+
3003
+ /**
3004
+ * Apply a horizontal Prewitt convolution to an image.
3005
+ *
3006
+ * # Arguments
3007
+ * * `img` - A PhotonImage.
3008
+ *
3009
+ * # Example
3010
+ *
3011
+ * ```no_run
3012
+ * // For example, to apply a horizontal Prewitt convolution effect:
3013
+ * use photon_rs::conv::prewitt_horizontal;
3014
+ * use photon_rs::native::open_image;
3015
+ *
3016
+ * let mut img = open_image("img.jpg").expect("File should open");
3017
+ * prewitt_horizontal(&mut img);
3018
+ * ```
3019
+ * @param {PhotonImage} photon_image
3020
+ */
3021
+ export function prewitt_horizontal(photon_image) {
3022
+ _assertClass(photon_image, PhotonImage);
3023
+ wasm.prewitt_horizontal(photon_image.__wbg_ptr);
3024
+ }
3025
+
3026
+ /**
3027
+ * Reduces an image to the primary colours.
3028
+ *
3029
+ * # Arguments
3030
+ * * `img` - A PhotonImage that contains a view into the image.
3031
+ * # Example
3032
+ *
3033
+ * ```no_run
3034
+ * // For example, to add a primary colour effect to an image of type `DynamicImage`:
3035
+ * use photon_rs::effects::primary;
3036
+ * use photon_rs::native::open_image;
3037
+ *
3038
+ * let mut img = open_image("img.jpg").expect("File should open");
3039
+ * primary(&mut img);
3040
+ * ```
3041
+ * @param {PhotonImage} img
3042
+ */
3043
+ export function primary(img) {
3044
+ _assertClass(img, PhotonImage);
3045
+ wasm.primary(img.__wbg_ptr);
3046
+ }
3047
+
3048
+ /**
3049
+ * Place a PhotonImage onto a 2D canvas.
3050
+ * @param {HTMLCanvasElement} canvas
3051
+ * @param {CanvasRenderingContext2D} ctx
3052
+ * @param {PhotonImage} new_image
3053
+ */
3054
+ export function putImageData(canvas, ctx, new_image) {
3055
+ _assertClass(new_image, PhotonImage);
3056
+ var ptr0 = new_image.__destroy_into_raw();
3057
+ wasm.putImageData(canvas, ctx, ptr0);
3058
+ }
3059
+
3060
+ /**
3061
+ * Convert an image to grayscale by setting a pixel's 3 RGB values to the Red channel's value.
3062
+ *
3063
+ * # Arguments
3064
+ * * `photon_image` - A PhotonImage.
3065
+ *
3066
+ * # Example
3067
+ *
3068
+ * ```no_run
3069
+ * use photon_rs::monochrome::r_grayscale;
3070
+ * use photon_rs::native::open_image;
3071
+ *
3072
+ * let mut img = open_image("img.jpg").expect("File should open");
3073
+ * r_grayscale(&mut img);
3074
+ * ```
3075
+ * @param {PhotonImage} photon_image
3076
+ */
3077
+ export function r_grayscale(photon_image) {
3078
+ _assertClass(photon_image, PhotonImage);
3079
+ wasm.r_grayscale(photon_image.__wbg_ptr);
3080
+ }
3081
+
3082
+ /**
3083
+ * Remove the Blue channel's influence in an image.
3084
+ *
3085
+ * # Arguments
3086
+ * * `img` - A PhotonImage.
3087
+ * * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter.
3088
+ *
3089
+ * # Example
3090
+ *
3091
+ * ```no_run
3092
+ * // For example, to remove the blue channel for blue channel pixel values less than 50:
3093
+ * use photon_rs::channels::remove_blue_channel;
3094
+ * use photon_rs::native::open_image;
3095
+ *
3096
+ * let mut img = open_image("img.jpg").expect("File should open");
3097
+ * remove_blue_channel(&mut img, 50_u8);
3098
+ * ```
3099
+ * @param {PhotonImage} img
3100
+ * @param {number} min_filter
3101
+ */
3102
+ export function remove_blue_channel(img, min_filter) {
3103
+ _assertClass(img, PhotonImage);
3104
+ wasm.remove_blue_channel(img.__wbg_ptr, min_filter);
3105
+ }
3106
+
3107
+ /**
3108
+ * Set a certain channel to zero, thus removing the channel's influence in the pixels' final rendered colour.
3109
+ *
3110
+ * # Arguments
3111
+ * * `img` - A PhotonImage.
3112
+ * * `channel` - The channel to be removed; must be a usize from 0 to 2, with 0 representing Red, 1 representing Green, and 2 representing Blue.
3113
+ * * `min_filter` - Minimum filter. Value between 0 and 255. Only remove the channel if the current pixel's channel value is less than this minimum filter. To completely
3114
+ * remove the channel, set this value to 255, to leave the channel as is, set to 0, and to set a channel to zero for a pixel whose red value is greater than 50,
3115
+ * then channel would be 0 and min_filter would be 50.
3116
+ *
3117
+ * # Example
3118
+ *
3119
+ * ```no_run
3120
+ * // For example, to remove the Red channel with a min_filter of 100:
3121
+ * use photon_rs::channels::remove_channel;
3122
+ * use photon_rs::native::open_image;
3123
+ *
3124
+ * let mut img = open_image("img.jpg").expect("File should open");
3125
+ * remove_channel(&mut img, 0_usize, 100_u8);
3126
+ * ```
3127
+ * @param {PhotonImage} img
3128
+ * @param {number} channel
3129
+ * @param {number} min_filter
3130
+ */
3131
+ export function remove_channel(img, channel, min_filter) {
3132
+ _assertClass(img, PhotonImage);
3133
+ wasm.remove_channel(img.__wbg_ptr, channel, min_filter);
3134
+ }
3135
+
3136
+ /**
3137
+ * Remove the Green channel's influence in an image.
3138
+ *
3139
+ * # Arguments
3140
+ * * `img` - A PhotonImage.
3141
+ * * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter.
3142
+ *
3143
+ * # Example
3144
+ *
3145
+ * ```no_run
3146
+ * // For example, to remove the green channel for green channel pixel values less than 50:
3147
+ * use photon_rs::channels::remove_green_channel;
3148
+ * use photon_rs::native::open_image;
3149
+ *
3150
+ * let mut img = open_image("img.jpg").expect("File should open");
3151
+ * remove_green_channel(&mut img, 50_u8);
3152
+ * ```
3153
+ * @param {PhotonImage} img
3154
+ * @param {number} min_filter
3155
+ */
3156
+ export function remove_green_channel(img, min_filter) {
3157
+ _assertClass(img, PhotonImage);
3158
+ wasm.remove_green_channel(img.__wbg_ptr, min_filter);
3159
+ }
3160
+
3161
+ /**
3162
+ * Remove the Red channel's influence in an image.
3163
+ *
3164
+ * # Arguments
3165
+ * * `img` - A PhotonImage.
3166
+ * * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter.
3167
+ *
3168
+ * # Example
3169
+ *
3170
+ * ```no_run
3171
+ * // For example, to remove the red channel for red channel pixel values less than 50:
3172
+ * use photon_rs::channels::remove_red_channel;
3173
+ * use photon_rs::native::open_image;
3174
+ *
3175
+ * let mut img = open_image("img.jpg").expect("File should open");
3176
+ * remove_red_channel(&mut img, 50_u8);
3177
+ * ```
3178
+ * @param {PhotonImage} img
3179
+ * @param {number} min_filter
3180
+ */
3181
+ export function remove_red_channel(img, min_filter) {
3182
+ _assertClass(img, PhotonImage);
3183
+ wasm.remove_red_channel(img.__wbg_ptr, min_filter);
3184
+ }
3185
+
3186
+ /**
3187
+ * Resample the PhotonImage.
3188
+ *
3189
+ * # Arguments
3190
+ * * `img` - A PhotonImage. See the PhotonImage struct for details.
3191
+ * * `dst_width` - Target width.
3192
+ * * `dst_height` - Target height.
3193
+ *
3194
+ * # Example
3195
+ *
3196
+ * ```no_run
3197
+ * // For example, to resample a PhotonImage to 1920x1080 size:
3198
+ * use photon_rs::native::open_image;
3199
+ * use photon_rs::transform::resample;
3200
+ *
3201
+ * let img = open_image("img.jpg").expect("File should open");
3202
+ * let rotated_img = resample(&img, 1920, 1080);
3203
+ * ```
3204
+ * @param {PhotonImage} img
3205
+ * @param {number} dst_width
3206
+ * @param {number} dst_height
3207
+ * @returns {PhotonImage}
3208
+ */
3209
+ export function resample(img, dst_width, dst_height) {
3210
+ _assertClass(img, PhotonImage);
3211
+ const ret = wasm.resample(img.__wbg_ptr, dst_width, dst_height);
3212
+ return PhotonImage.__wrap(ret);
3213
+ }
3214
+
3215
+ /**
3216
+ * Resize an image.
3217
+ *
3218
+ * # Arguments
3219
+ * * `img` - A PhotonImage.
3220
+ * * `width` - New width.
3221
+ * * `height` - New height.
3222
+ * * `sampling_filter` - Nearest = 1, Triangle = 2, CatmullRom = 3, Gaussian = 4, Lanczos3 = 5
3223
+ * @param {PhotonImage} photon_img
3224
+ * @param {number} width
3225
+ * @param {number} height
3226
+ * @param {SamplingFilter} sampling_filter
3227
+ * @returns {PhotonImage}
3228
+ */
3229
+ export function resize(photon_img, width, height, sampling_filter) {
3230
+ _assertClass(photon_img, PhotonImage);
3231
+ const ret = wasm.resize(photon_img.__wbg_ptr, width, height, sampling_filter);
3232
+ return PhotonImage.__wrap(ret);
3233
+ }
3234
+
3235
+ /**
3236
+ * Resize an image on the web.
3237
+ *
3238
+ * # Arguments
3239
+ * * `img` - A PhotonImage.
3240
+ * * `width` - New width.
3241
+ * * `height` - New height.
3242
+ * * `sampling_filter` - Nearest = 1, Triangle = 2, CatmullRom = 3, Gaussian = 4, Lanczos3 = 5
3243
+ * @param {PhotonImage} photon_img
3244
+ * @param {number} width
3245
+ * @param {number} height
3246
+ * @param {SamplingFilter} sampling_filter
3247
+ * @returns {HTMLCanvasElement}
3248
+ */
3249
+ export function resize_img_browser(photon_img, width, height, sampling_filter) {
3250
+ _assertClass(photon_img, PhotonImage);
3251
+ const ret = wasm.resize_img_browser(photon_img.__wbg_ptr, width, height, sampling_filter);
3252
+ return ret;
3253
+ }
3254
+
3255
+ /**
3256
+ * Rotate the PhotonImage on an arbitrary angle
3257
+ * A rotated PhotonImage is returned.
3258
+ *
3259
+ * # Arguments
3260
+ * * `img` - A PhotonImage. See the PhotonImage struct for details.
3261
+ * * `angle` - Rotation angle in degrees.
3262
+ *
3263
+ * # Example
3264
+ *
3265
+ * ```no_run
3266
+ * // For example, to rotate a PhotonImage by 30 degrees:
3267
+ * use photon_rs::native::open_image;
3268
+ * use photon_rs::transform::rotate;
3269
+ *
3270
+ * let img = open_image("img.jpg").expect("File should open");
3271
+ * let rotated_img = rotate(&img, 30.0);
3272
+ * ```
3273
+ * @param {PhotonImage} photon_img
3274
+ * @param {number} angle
3275
+ * @returns {PhotonImage}
3276
+ */
3277
+ export function rotate(photon_img, angle) {
3278
+ _assertClass(photon_img, PhotonImage);
3279
+ const ret = wasm.rotate(photon_img.__wbg_ptr, angle);
3280
+ return PhotonImage.__wrap(ret);
3281
+ }
3282
+
3283
+ /**
3284
+ * ! [temp] Check if WASM is supported.
3285
+ */
3286
+ export function run() {
3287
+ const ret = wasm.run();
3288
+ if (ret[1]) {
3289
+ throw takeFromExternrefTable0(ret[0]);
3290
+ }
3291
+ }
3292
+
3293
+ /**
3294
+ * Solarization on the Red and Blue channels.
3295
+ *
3296
+ * # Arguments
3297
+ * * `img` - A PhotonImage.
3298
+ * # Example
3299
+ *
3300
+ * ```no_run
3301
+ * use photon_rs::filters::ryo;
3302
+ * use photon_rs::native::open_image;
3303
+ *
3304
+ * let mut img = open_image("img.jpg").expect("File should open");
3305
+ * ryo(&mut img);
3306
+ * ```
3307
+ * @param {PhotonImage} photon_image
3308
+ */
3309
+ export function ryo(photon_image) {
3310
+ _assertClass(photon_image, PhotonImage);
3311
+ wasm.ryo(photon_image.__wbg_ptr);
3312
+ }
3313
+
3314
+ /**
3315
+ * Increase the image's saturation by converting each pixel's colour to the HSL colour space
3316
+ * and increasing the colour's saturation.
3317
+ * # Arguments
3318
+ * * `img` - A PhotonImage.
3319
+ * * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by.
3320
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
3321
+ * Increasing saturation by 80% would be represented by a `level` of 0.8
3322
+ *
3323
+ * # Example
3324
+ * ```no_run
3325
+ * // For example to increase saturation by 10% in the HSL colour space:
3326
+ * use photon_rs::colour_spaces::saturate_hsl;
3327
+ * use photon_rs::native::open_image;
3328
+ *
3329
+ * // Open the image. A PhotonImage is returned.
3330
+ * let mut img = open_image("img.jpg").expect("File should open");
3331
+ * saturate_hsl(&mut img, 0.1_f32);
3332
+ * ```
3333
+ * @param {PhotonImage} img
3334
+ * @param {number} level
3335
+ */
3336
+ export function saturate_hsl(img, level) {
3337
+ _assertClass(img, PhotonImage);
3338
+ wasm.saturate_hsl(img.__wbg_ptr, level);
3339
+ }
3340
+
3341
+ /**
3342
+ * Increase the image's saturation in the HSLuv colour space.
3343
+ * # Arguments
3344
+ * * `img` - A PhotonImage.
3345
+ * * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by.
3346
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
3347
+ * Increasing saturation by 80% would be represented by a `level` of 0.8
3348
+ *
3349
+ * # Example
3350
+ * ```no_run
3351
+ * // For example to increase saturation by 40% in the HSLuv colour space:
3352
+ * use photon_rs::colour_spaces::saturate_hsluv;
3353
+ * use photon_rs::native::open_image;
3354
+ *
3355
+ * // Open the image. A PhotonImage is returned.
3356
+ * let mut img = open_image("img.jpg").expect("File should open");
3357
+ * saturate_hsluv(&mut img, 0.4_f32);
3358
+ * ```
3359
+ * @param {PhotonImage} img
3360
+ * @param {number} level
3361
+ */
3362
+ export function saturate_hsluv(img, level) {
3363
+ _assertClass(img, PhotonImage);
3364
+ wasm.saturate_hsluv(img.__wbg_ptr, level);
3365
+ }
3366
+
3367
+ /**
3368
+ * Increase the image's saturation in the HSV colour space.
3369
+ * # Arguments
3370
+ * * `img` - A PhotonImage.
3371
+ * * `level` - Float value from 0 to 1 representing the level by which to increase the saturation by.
3372
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
3373
+ * Increasing saturation by 80% would be represented by a `level` of 0.8
3374
+ *
3375
+ * # Example
3376
+ * ```no_run
3377
+ * // For example to increase saturation by 30% in the HSV colour space:
3378
+ * use photon_rs::colour_spaces::saturate_hsv;
3379
+ * use photon_rs::native::open_image;
3380
+ *
3381
+ * // Open the image. A PhotonImage is returned.
3382
+ * let mut img = open_image("img.jpg").expect("File should open");
3383
+ * saturate_hsv(&mut img, 0.3_f32);
3384
+ * ```
3385
+ * @param {PhotonImage} img
3386
+ * @param {number} level
3387
+ */
3388
+ export function saturate_hsv(img, level) {
3389
+ _assertClass(img, PhotonImage);
3390
+ wasm.saturate_hsv(img.__wbg_ptr, level);
3391
+ }
3392
+
3393
+ /**
3394
+ * Increase the image's saturation in the LCh colour space.
3395
+ * # Arguments
3396
+ * * `img` - A PhotonImage.
3397
+ * * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by.
3398
+ * The `level` must be from 0 to 1 in floating-point, `f32` format.
3399
+ * Increasing saturation by 80% would be represented by a `level` of 0.8
3400
+ *
3401
+ * # Example
3402
+ * ```no_run
3403
+ * // For example to increase saturation by 40% in the Lch colour space:
3404
+ * use photon_rs::colour_spaces::saturate_lch;
3405
+ * use photon_rs::native::open_image;
3406
+ *
3407
+ * // Open the image. A PhotonImage is returned.
3408
+ * let mut img = open_image("img.jpg").expect("File should open");
3409
+ * saturate_lch(&mut img, 0.4_f32);
3410
+ * ```
3411
+ * @param {PhotonImage} img
3412
+ * @param {number} level
3413
+ */
3414
+ export function saturate_lch(img, level) {
3415
+ _assertClass(img, PhotonImage);
3416
+ wasm.saturate_lch(img.__wbg_ptr, level);
3417
+ }
3418
+
3419
+ /**
3420
+ * Resize image using seam carver.
3421
+ * Resize only if new dimensions are smaller, than original image.
3422
+ * # NOTE: This is still experimental feature, and pretty slow.
3423
+ *
3424
+ * # Arguments
3425
+ * * `img` - A PhotonImage.
3426
+ * * `width` - New width.
3427
+ * * `height` - New height.
3428
+ *
3429
+ * # Example
3430
+ *
3431
+ * ```no_run
3432
+ * // For example, resize image using seam carver:
3433
+ * use photon_rs::native::open_image;
3434
+ * use photon_rs::transform::seam_carve;
3435
+ * use photon_rs::PhotonImage;
3436
+ *
3437
+ * let img = open_image("img.jpg").expect("File should open");
3438
+ * let result: PhotonImage = seam_carve(&img, 100_u32, 100_u32);
3439
+ * ```
3440
+ * @param {PhotonImage} img
3441
+ * @param {number} width
3442
+ * @param {number} height
3443
+ * @returns {PhotonImage}
3444
+ */
3445
+ export function seam_carve(img, width, height) {
3446
+ _assertClass(img, PhotonImage);
3447
+ const ret = wasm.seam_carve(img.__wbg_ptr, width, height);
3448
+ return PhotonImage.__wrap(ret);
3449
+ }
3450
+
3451
+ /**
3452
+ * Selectively change pixel colours which are similar to the reference colour provided.
3453
+ *
3454
+ * Similarity between two colours is calculated via the CIE76 formula.
3455
+ * Only changes the color of a pixel if its similarity to the reference colour is within the range in the algorithm.
3456
+ * For example, with this function, a user can change the color of all blue pixels by mixing them with red by 10%.
3457
+ * # Arguments
3458
+ * * `photon_image` - A PhotonImage.
3459
+ * * `ref_color` - The `RGB` value of the reference color (to be compared to)
3460
+ * * `new_color` - The `RGB` value of the new color (to be mixed with the matched pixels)
3461
+ * * `fraction` - The amount of mixing the new colour with the matched pixels
3462
+ *
3463
+ * # Example
3464
+ *
3465
+ * ```no_run
3466
+ * // For example, to only change the color of pixels that are similar to the RGB value RGB{200, 120, 30} by mixing RGB{30, 120, 200} with 25%:
3467
+ * use photon_rs::Rgb;
3468
+ * use photon_rs::channels::selective_color_convert;
3469
+ * use photon_rs::native::open_image;
3470
+ *
3471
+ * let ref_color = Rgb::new(200, 120, 30);
3472
+ * let new_color = Rgb::new(30, 120, 200);
3473
+ * let mut img = open_image("img.jpg").expect("File should open");
3474
+ * selective_color_convert(&mut img, ref_color, new_color, 0.25);
3475
+ * ```
3476
+ * @param {PhotonImage} photon_image
3477
+ * @param {Rgb} ref_color
3478
+ * @param {Rgb} new_color
3479
+ * @param {number} fraction
3480
+ */
3481
+ export function selective_color_convert(photon_image, ref_color, new_color, fraction) {
3482
+ _assertClass(photon_image, PhotonImage);
3483
+ _assertClass(ref_color, Rgb);
3484
+ var ptr0 = ref_color.__destroy_into_raw();
3485
+ _assertClass(new_color, Rgb);
3486
+ var ptr1 = new_color.__destroy_into_raw();
3487
+ wasm.selective_color_convert(photon_image.__wbg_ptr, ptr0, ptr1, fraction);
3488
+ }
3489
+
3490
+ /**
3491
+ * Selectively desaturate pixel colours which are similar to the reference colour provided.
3492
+ *
3493
+ * Similarity between two colours is calculated via the CIE76 formula.
3494
+ * Only desaturates the hue of a pixel if its similarity to the reference colour is within the range in the algorithm.
3495
+ * For example, if a user wishes all pixels that are blue to be desaturated by 0.1, they can selectively specify only the blue pixels to be changed.
3496
+ * # Arguments
3497
+ * * `img` - A PhotonImage.
3498
+ * * `ref_color` - The `RGB` value of the reference color (to be compared to)
3499
+ * * `amt` - The amount of desaturate the colour by.
3500
+ *
3501
+ * # Example
3502
+ *
3503
+ * ```no_run
3504
+ * // For example, to only desaturate the pixels that are similar to the RGB value RGB{20, 40, 60}:
3505
+ * use photon_rs::Rgb;
3506
+ * use photon_rs::channels::selective_desaturate;
3507
+ * use photon_rs::native::open_image;
3508
+ *
3509
+ * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
3510
+ * let mut img = open_image("img.jpg").expect("File should open");
3511
+ * selective_desaturate(&mut img, ref_color, 0.1_f32);
3512
+ * ```
3513
+ * @param {PhotonImage} img
3514
+ * @param {Rgb} ref_color
3515
+ * @param {number} amt
3516
+ */
3517
+ export function selective_desaturate(img, ref_color, amt) {
3518
+ _assertClass(img, PhotonImage);
3519
+ _assertClass(ref_color, Rgb);
3520
+ var ptr0 = ref_color.__destroy_into_raw();
3521
+ wasm.selective_desaturate(img.__wbg_ptr, ptr0, amt);
3522
+ }
3523
+
3524
+ /**
3525
+ * Selectively changes a pixel to greyscale if it is *not* visually similar or close to the colour specified.
3526
+ * Only changes the colour of a pixel if its RGB values are within a specified range.
3527
+ *
3528
+ * (Similarity between two colours is calculated via the CIE76 formula.)
3529
+ * For example, if a user wishes all pixels that are *NOT* blue to be displayed in greyscale, they can selectively specify only the blue pixels to be
3530
+ * kept in the photo.
3531
+ * # Arguments
3532
+ * * `img` - A PhotonImage.
3533
+ * * `ref_color` - The `RGB` value of the reference color (to be compared to)
3534
+ *
3535
+ * # Example
3536
+ *
3537
+ * ```no_run
3538
+ * // For example, to greyscale all pixels that are *not* visually similar to the RGB colour RGB{20, 40, 60}:
3539
+ * use photon_rs::Rgb;
3540
+ * use photon_rs::channels::selective_greyscale;
3541
+ * use photon_rs::native::open_image;
3542
+ *
3543
+ * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
3544
+ * let mut img = open_image("img.jpg").expect("File should open");
3545
+ * selective_greyscale(img, ref_color);
3546
+ * ```
3547
+ * @param {PhotonImage} photon_image
3548
+ * @param {Rgb} ref_color
3549
+ */
3550
+ export function selective_greyscale(photon_image, ref_color) {
3551
+ _assertClass(photon_image, PhotonImage);
3552
+ var ptr0 = photon_image.__destroy_into_raw();
3553
+ _assertClass(ref_color, Rgb);
3554
+ var ptr1 = ref_color.__destroy_into_raw();
3555
+ wasm.selective_greyscale(ptr0, ptr1);
3556
+ }
3557
+
3558
+ /**
3559
+ * Selective hue rotation.
3560
+ *
3561
+ * Only rotate the hue of a pixel if its RGB values are within a specified range.
3562
+ * This function only rotates a pixel's hue to another if it is visually similar to the colour specified.
3563
+ * For example, if a user wishes all pixels that are blue to be changed to red, they can selectively specify only the blue pixels to be changed.
3564
+ * # Arguments
3565
+ * * `img` - A PhotonImage.
3566
+ * * `ref_color` - The `RGB` value of the reference color (to be compared to)
3567
+ * * `degrees` - The amount of degrees to hue rotate by.
3568
+ *
3569
+ * # Example
3570
+ *
3571
+ * ```no_run
3572
+ * // For example, to only rotate the pixels that are of RGB value RGB{20, 40, 60}:
3573
+ * use photon_rs::Rgb;
3574
+ * use photon_rs::channels::selective_hue_rotate;
3575
+ * use photon_rs::native::open_image;
3576
+ *
3577
+ * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
3578
+ * let mut img = open_image("img.jpg").expect("File should open");
3579
+ * selective_hue_rotate(&mut img, ref_color, 180_f32);
3580
+ * ```
3581
+ * @param {PhotonImage} photon_image
3582
+ * @param {Rgb} ref_color
3583
+ * @param {number} degrees
3584
+ */
3585
+ export function selective_hue_rotate(photon_image, ref_color, degrees) {
3586
+ _assertClass(photon_image, PhotonImage);
3587
+ _assertClass(ref_color, Rgb);
3588
+ var ptr0 = ref_color.__destroy_into_raw();
3589
+ wasm.selective_hue_rotate(photon_image.__wbg_ptr, ptr0, degrees);
3590
+ }
3591
+
3592
+ /**
3593
+ * Selectively lighten an image.
3594
+ *
3595
+ * Only lighten the hue of a pixel if its colour matches or is similar to the RGB colour specified.
3596
+ * For example, if a user wishes all pixels that are blue to be lightened, they can selectively specify only the blue pixels to be changed.
3597
+ * # Arguments
3598
+ * * `img` - A PhotonImage.
3599
+ * * `ref_color` - The `RGB` value of the reference color (to be compared to)
3600
+ * * `amt` - The level from 0 to 1 to lighten the hue by. Increasing by 10% would have an `amt` of 0.1
3601
+ *
3602
+ * # Example
3603
+ *
3604
+ * ```no_run
3605
+ * // For example, to only lighten the pixels that are of or similar to RGB value RGB{20, 40, 60}:
3606
+ * use photon_rs::Rgb;
3607
+ * use photon_rs::channels::selective_lighten;
3608
+ * use photon_rs::native::open_image;
3609
+ *
3610
+ * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
3611
+ * let mut img = open_image("img.jpg").expect("File should open");
3612
+ * selective_lighten(&mut img, ref_color, 0.2_f32);
3613
+ * ```
3614
+ * @param {PhotonImage} img
3615
+ * @param {Rgb} ref_color
3616
+ * @param {number} amt
3617
+ */
3618
+ export function selective_lighten(img, ref_color, amt) {
3619
+ _assertClass(img, PhotonImage);
3620
+ _assertClass(ref_color, Rgb);
3621
+ var ptr0 = ref_color.__destroy_into_raw();
3622
+ wasm.selective_lighten(img.__wbg_ptr, ptr0, amt);
3623
+ }
3624
+
3625
+ /**
3626
+ * Selectively saturate pixel colours which are similar to the reference colour provided.
3627
+ *
3628
+ * Similarity between two colours is calculated via the CIE76 formula.
3629
+ * Only saturates the hue of a pixel if its similarity to the reference colour is within the range in the algorithm.
3630
+ * For example, if a user wishes all pixels that are blue to have an increase in saturation by 10%, they can selectively specify only the blue pixels to be changed.
3631
+ * # Arguments
3632
+ * * `img` - A PhotonImage.
3633
+ * * `ref_color` - The `RGB` value of the reference color (to be compared to)
3634
+ * * `amt` - The amount of saturate the colour by.
3635
+ *
3636
+ * # Example
3637
+ *
3638
+ * ```no_run
3639
+ * // For example, to only increase the saturation of pixels that are similar to the RGB value RGB{20, 40, 60}:
3640
+ * use photon_rs::Rgb;
3641
+ * use photon_rs::channels::selective_saturate;
3642
+ * use photon_rs::native::open_image;
3643
+ *
3644
+ * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
3645
+ * let mut img = open_image("img.jpg").expect("File should open");
3646
+ * selective_saturate(&mut img, ref_color, 0.1_f32);
3647
+ * ```
3648
+ * @param {PhotonImage} img
3649
+ * @param {Rgb} ref_color
3650
+ * @param {number} amt
3651
+ */
3652
+ export function selective_saturate(img, ref_color, amt) {
3653
+ _assertClass(img, PhotonImage);
3654
+ _assertClass(ref_color, Rgb);
3655
+ var ptr0 = ref_color.__destroy_into_raw();
3656
+ wasm.selective_saturate(img.__wbg_ptr, ptr0, amt);
3657
+ }
3658
+
3659
+ /**
3660
+ * Convert an image to sepia.
3661
+ *
3662
+ * # Arguments
3663
+ * * `photon_image` - A PhotonImage.
3664
+ * # Example
3665
+ *
3666
+ * ```no_run
3667
+ * // For example, to sepia an image of type `PhotonImage`:
3668
+ * use photon_rs::monochrome::sepia;
3669
+ * use photon_rs::native::open_image;
3670
+ *
3671
+ * let mut img = open_image("img.jpg").expect("File should open");
3672
+ * sepia(&mut img);
3673
+ * ```
3674
+ * @param {PhotonImage} img
3675
+ */
3676
+ export function sepia(img) {
3677
+ _assertClass(img, PhotonImage);
3678
+ wasm.sepia(img.__wbg_ptr);
3679
+ }
3680
+
3681
+ /**
3682
+ * Sharpen an image.
3683
+ *
3684
+ * # Arguments
3685
+ * * `img` - A PhotonImage.
3686
+ *
3687
+ * # Example
3688
+ *
3689
+ * ```no_run
3690
+ * // For example, to sharpen an image:
3691
+ * use photon_rs::conv::sharpen;
3692
+ * use photon_rs::native::open_image;
3693
+ *
3694
+ * let mut img = open_image("img.jpg").expect("File should open");
3695
+ * sharpen(&mut img);
3696
+ * ```
3697
+ * Adds a constant to a select R, G, or B channel's value.
3698
+ * @param {PhotonImage} photon_image
3699
+ */
3700
+ export function sharpen(photon_image) {
3701
+ _assertClass(photon_image, PhotonImage);
3702
+ wasm.sharpen(photon_image.__wbg_ptr);
3703
+ }
3704
+
3705
+ /**
3706
+ * Shear the image along the X axis.
3707
+ * A sheared PhotonImage is returned.
3708
+ *
3709
+ * # Arguments
3710
+ * * `img` - A PhotonImage. See the PhotonImage struct for details.
3711
+ * * `shear` - Amount to shear.
3712
+ *
3713
+ * # Example
3714
+ *
3715
+ * ```no_run
3716
+ * // For example, to shear an image by 0.5:
3717
+ * use photon_rs::native::open_image;
3718
+ * use photon_rs::transform::shearx;
3719
+ *
3720
+ * let img = open_image("img.jpg").expect("File should open");
3721
+ * let sheared_img = shearx(&img, 0.5);
3722
+ * ```
3723
+ * @param {PhotonImage} photon_img
3724
+ * @param {number} shear
3725
+ * @returns {PhotonImage}
3726
+ */
3727
+ export function shearx(photon_img, shear) {
3728
+ _assertClass(photon_img, PhotonImage);
3729
+ const ret = wasm.shearx(photon_img.__wbg_ptr, shear);
3730
+ return PhotonImage.__wrap(ret);
3731
+ }
3732
+
3733
+ /**
3734
+ * Shear the image along the Y axis.
3735
+ * A sheared PhotonImage is returned.
3736
+ *
3737
+ * # Arguments
3738
+ * * `img` - A PhotonImage. See the PhotonImage struct for details.
3739
+ * * `shear` - Amount to shear.
3740
+ *
3741
+ * # Example
3742
+ *
3743
+ * ```no_run
3744
+ * // For example, to shear an image by 0.5:
3745
+ * use photon_rs::native::open_image;
3746
+ * use photon_rs::transform::sheary;
3747
+ *
3748
+ * let img = open_image("img.jpg").expect("File should open");
3749
+ * let sheared_img = sheary(&img, 0.5);
3750
+ * ```
3751
+ * @param {PhotonImage} photon_img
3752
+ * @param {number} shear
3753
+ * @returns {PhotonImage}
3754
+ */
3755
+ export function sheary(photon_img, shear) {
3756
+ _assertClass(photon_img, PhotonImage);
3757
+ const ret = wasm.sheary(photon_img.__wbg_ptr, shear);
3758
+ return PhotonImage.__wrap(ret);
3759
+ }
3760
+
3761
+ /**
3762
+ * Convert an image to grayscale by setting a pixel's 3 RGB values to a chosen channel's value.
3763
+ *
3764
+ * # Arguments
3765
+ * * `photon_image` - A PhotonImage.
3766
+ * * `channel` - A usize representing the channel from 0 to 2. O represents the Red channel, 1 the Green channel, and 2 the Blue channel.
3767
+ *
3768
+ * # Example
3769
+ * To grayscale using only values from the Red channel:
3770
+ * ```no_run
3771
+ * use photon_rs::monochrome::single_channel_grayscale;
3772
+ * use photon_rs::native::open_image;
3773
+ *
3774
+ * let mut img = open_image("img.jpg").expect("File should open");
3775
+ * single_channel_grayscale(&mut img, 0_usize);
3776
+ * ```
3777
+ * @param {PhotonImage} photon_image
3778
+ * @param {number} channel
3779
+ */
3780
+ export function single_channel_grayscale(photon_image, channel) {
3781
+ _assertClass(photon_image, PhotonImage);
3782
+ wasm.single_channel_grayscale(photon_image.__wbg_ptr, channel);
3783
+ }
3784
+
3785
+ /**
3786
+ * Apply a global Sobel filter to an image
3787
+ *
3788
+ * Each pixel is calculated as the magnitude of the horizontal and vertical components of the Sobel filter,
3789
+ * ie if X is the horizontal sobel and Y is the vertical, for each pixel, we calculate sqrt(X^2 + Y^2)
3790
+ *
3791
+ * # Arguments
3792
+ * * `img` - A PhotonImage.
3793
+ *
3794
+ * # Example
3795
+ *
3796
+ * ```no_run
3797
+ * // For example, to apply a global Sobel filter:
3798
+ * use photon_rs::conv::sobel_global;
3799
+ * use photon_rs::native::open_image;
3800
+ *
3801
+ * let mut img = open_image("img.jpg").expect("File should open");
3802
+ * sobel_global(&mut img);
3803
+ * ```
3804
+ * @param {PhotonImage} photon_image
3805
+ */
3806
+ export function sobel_global(photon_image) {
3807
+ _assertClass(photon_image, PhotonImage);
3808
+ wasm.sobel_global(photon_image.__wbg_ptr);
3809
+ }
3810
+
3811
+ /**
3812
+ * Apply a horizontal Sobel filter to an image.
3813
+ *
3814
+ * # Arguments
3815
+ * * `img` - A PhotonImage.
3816
+ *
3817
+ * # Example
3818
+ *
3819
+ * ```no_run
3820
+ * // For example, to apply a horizontal Sobel filter:
3821
+ * use photon_rs::conv::sobel_horizontal;
3822
+ * use photon_rs::native::open_image;
3823
+ *
3824
+ * let mut img = open_image("img.jpg").expect("File should open");
3825
+ * sobel_horizontal(&mut img);
3826
+ * ```
3827
+ * @param {PhotonImage} photon_image
3828
+ */
3829
+ export function sobel_horizontal(photon_image) {
3830
+ _assertClass(photon_image, PhotonImage);
3831
+ wasm.sobel_horizontal(photon_image.__wbg_ptr);
3832
+ }
3833
+
3834
+ /**
3835
+ * Apply a vertical Sobel filter to an image.
3836
+ *
3837
+ * # Arguments
3838
+ * * `img` - A PhotonImage.
3839
+ *
3840
+ * # Example
3841
+ *
3842
+ * ```no_run
3843
+ * // For example, to apply a vertical Sobel filter:
3844
+ * use photon_rs::conv::sobel_vertical;
3845
+ * use photon_rs::native::open_image;
3846
+ *
3847
+ * let mut img = open_image("img.jpg").expect("File should open");
3848
+ * sobel_vertical(&mut img);
3849
+ * ```
3850
+ * @param {PhotonImage} photon_image
3851
+ */
3852
+ export function sobel_vertical(photon_image) {
3853
+ _assertClass(photon_image, PhotonImage);
3854
+ wasm.sobel_vertical(photon_image.__wbg_ptr);
3855
+ }
3856
+
3857
+ /**
3858
+ * Applies a solarizing effect to an image.
3859
+ *
3860
+ * # Arguments
3861
+ * * `img` - A PhotonImage that contains a view into the image.
3862
+ * # Example
3863
+ *
3864
+ * ```no_run
3865
+ * // For example, to colorize an image of type `PhotonImage`:
3866
+ * use photon_rs::effects::solarize;
3867
+ * use photon_rs::native::open_image;
3868
+ *
3869
+ * let mut img = open_image("img.jpg").expect("File should open");
3870
+ * solarize(&mut img);
3871
+ * ```
3872
+ * @param {PhotonImage} photon_image
3873
+ */
3874
+ export function solarize(photon_image) {
3875
+ _assertClass(photon_image, PhotonImage);
3876
+ wasm.solarize(photon_image.__wbg_ptr);
3877
+ }
3878
+
3879
+ /**
3880
+ * Applies a solarizing effect to an image and returns the resulting PhotonImage.
3881
+ *
3882
+ * # Arguments
3883
+ * * `img` - A PhotonImage that contains a view into the image.
3884
+ * # Example
3885
+ *
3886
+ * ```no_run
3887
+ * // For example, to solarize "retimg" an image of type `PhotonImage`:
3888
+ * use photon_rs::effects::solarize_retimg;
3889
+ * use photon_rs::native::open_image;
3890
+ * use photon_rs::PhotonImage;
3891
+ *
3892
+ * let img = open_image("img.jpg").expect("File should open");
3893
+ * let result: PhotonImage = solarize_retimg(&img);
3894
+ * ```
3895
+ * @param {PhotonImage} photon_image
3896
+ * @returns {PhotonImage}
3897
+ */
3898
+ export function solarize_retimg(photon_image) {
3899
+ _assertClass(photon_image, PhotonImage);
3900
+ const ret = wasm.solarize_retimg(photon_image.__wbg_ptr);
3901
+ return PhotonImage.__wrap(ret);
3902
+ }
3903
+
3904
+ /**
3905
+ * Swap two channels.
3906
+ *
3907
+ * # Arguments
3908
+ * * `img` - A PhotonImage.
3909
+ * * `channel1` - An index from 0 to 2, representing the Red, Green or Blue channels respectively. Red would be represented by 0, Green by 1, and Blue by 2.
3910
+ * * `channel2` - An index from 0 to 2, representing the Red, Green or Blue channels respectively. Same as above.
3911
+ *
3912
+ * # Example
3913
+ *
3914
+ * ```no_run
3915
+ * // For example, to swap the values of the Red channel with the values of the Blue channel:
3916
+ * use photon_rs::channels::swap_channels;
3917
+ * use photon_rs::native::open_image;
3918
+ *
3919
+ * let mut img = open_image("img.jpg").expect("File should open");
3920
+ * swap_channels(&mut img, 0_usize, 2_usize);
3921
+ * ```
3922
+ * @param {PhotonImage} img
3923
+ * @param {number} channel1
3924
+ * @param {number} channel2
3925
+ */
3926
+ export function swap_channels(img, channel1, channel2) {
3927
+ _assertClass(img, PhotonImage);
3928
+ wasm.swap_channels(img.__wbg_ptr, channel1, channel2);
3929
+ }
3930
+
3931
+ /**
3932
+ * Threshold an image using a standard thresholding algorithm.
3933
+ *
3934
+ * # Arguments
3935
+ * * `photon_image` - A PhotonImage.
3936
+ * * `threshold` - The amount the image should be thresholded by from 0 to 255.
3937
+ * # Example
3938
+ *
3939
+ * ```no_run
3940
+ * // For example, to threshold an image of type `PhotonImage`:
3941
+ * use photon_rs::monochrome::threshold;
3942
+ * use photon_rs::native::open_image;
3943
+ *
3944
+ * let mut img = open_image("img.jpg").expect("File should open");
3945
+ * threshold(&mut img, 30_u32);
3946
+ * ```
3947
+ * @param {PhotonImage} img
3948
+ * @param {number} threshold
3949
+ */
3950
+ export function threshold(img, threshold) {
3951
+ _assertClass(img, PhotonImage);
3952
+ wasm.threshold(img.__wbg_ptr, threshold);
3953
+ }
3954
+
3955
+ /**
3956
+ * Tint an image by adding an offset to averaged RGB channel values.
3957
+ *
3958
+ * # Arguments
3959
+ * * `img` - A PhotonImage that contains a view into the image.
3960
+ * * `r_offset` - The amount the R channel should be incremented by.
3961
+ * * `g_offset` - The amount the G channel should be incremented by.
3962
+ * * `b_offset` - The amount the B channel should be incremented by.
3963
+ * # Example
3964
+ *
3965
+ * ```no_run
3966
+ * // For example, to tint an image of type `PhotonImage`:
3967
+ * use photon_rs::effects::tint;
3968
+ * use photon_rs::native::open_image;
3969
+ *
3970
+ * let mut img = open_image("img.jpg").expect("File should open");
3971
+ * tint(&mut img, 10_u32, 20_u32, 15_u32);
3972
+ * ```
3973
+ * @param {PhotonImage} photon_image
3974
+ * @param {number} r_offset
3975
+ * @param {number} g_offset
3976
+ * @param {number} b_offset
3977
+ */
3978
+ export function tint(photon_image, r_offset, g_offset, b_offset) {
3979
+ _assertClass(photon_image, PhotonImage);
3980
+ wasm.tint(photon_image.__wbg_ptr, r_offset, g_offset, b_offset);
3981
+ }
3982
+
3983
+ /**
3984
+ * Convert a PhotonImage to JS-compatible ImageData.
3985
+ * @param {PhotonImage} photon_image
3986
+ * @returns {ImageData}
3987
+ */
3988
+ export function to_image_data(photon_image) {
3989
+ _assertClass(photon_image, PhotonImage);
3990
+ var ptr0 = photon_image.__destroy_into_raw();
3991
+ const ret = wasm.to_image_data(ptr0);
3992
+ return ret;
3993
+ }
3994
+
3995
+ /**
3996
+ * Convert ImageData to a raw pixel vec of u8s.
3997
+ * @param {ImageData} imgdata
3998
+ * @returns {Uint8Array}
3999
+ */
4000
+ export function to_raw_pixels(imgdata) {
4001
+ const ret = wasm.to_raw_pixels(imgdata);
4002
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
4003
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
4004
+ return v1;
4005
+ }
4006
+
4007
+ /**
4008
+ * Vertical strips. Divide an image into a series of equal-width strips, for an artistic effect.
4009
+ *
4010
+ * # Arguments
4011
+ * * `img` - A PhotonImage that contains a view into the image.
4012
+ * * `num_strips` - The numbder of strips
4013
+ * # Example
4014
+ *
4015
+ * ```no_run
4016
+ * // For example, to draw vertical strips on a `PhotonImage`:
4017
+ * use photon_rs::effects::vertical_strips;
4018
+ * use photon_rs::native::open_image;
4019
+ *
4020
+ * let mut img = open_image("img.jpg").expect("File should open");
4021
+ * vertical_strips(&mut img, 8u8);
4022
+ * ```
4023
+ * @param {PhotonImage} photon_image
4024
+ * @param {number} num_strips
4025
+ */
4026
+ export function vertical_strips(photon_image, num_strips) {
4027
+ _assertClass(photon_image, PhotonImage);
4028
+ wasm.vertical_strips(photon_image.__wbg_ptr, num_strips);
4029
+ }
4030
+
4031
+ /**
4032
+ * Add a watermark to an image.
4033
+ *
4034
+ * # Arguments
4035
+ * * `img` - A DynamicImage that contains a view into the image.
4036
+ * * `watermark` - The watermark to be placed onto the `img` image.
4037
+ * * `x` - The x coordinate where the watermark's top corner should be positioned.
4038
+ * * `y` - The y coordinate where the watermark's top corner should be positioned.
4039
+ * # Example
4040
+ *
4041
+ * ```no_run
4042
+ * // For example, to add a watermark to an image at x: 30, y: 40:
4043
+ * use photon_rs::multiple::watermark;
4044
+ * use photon_rs::native::open_image;
4045
+ *
4046
+ * let mut img = open_image("img.jpg").expect("File should open");
4047
+ * let water_mark = open_image("watermark.jpg").expect("File should open");
4048
+ * watermark(&mut img, &water_mark, 30_i64, 40_i64);
4049
+ * ```
4050
+ * @param {PhotonImage} img
4051
+ * @param {PhotonImage} watermark
4052
+ * @param {bigint} x
4053
+ * @param {bigint} y
4054
+ */
4055
+ export function watermark(img, watermark, x, y) {
4056
+ _assertClass(img, PhotonImage);
4057
+ _assertClass(watermark, PhotonImage);
4058
+ wasm.watermark(img.__wbg_ptr, watermark.__wbg_ptr, x, y);
4059
+ }
4060
+
4061
+ function __wbg_get_imports() {
4062
+ const import0 = {
4063
+ __proto__: null,
4064
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
4065
+ const ret = debugString(arg1);
4066
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4067
+ const len1 = WASM_VECTOR_LEN;
4068
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4069
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4070
+ },
4071
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
4072
+ const ret = arg0 === undefined;
4073
+ return ret;
4074
+ },
4075
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
4076
+ throw new Error(getStringFromWasm0(arg0, arg1));
4077
+ },
4078
+ __wbg_appendChild_dea38765a26d346d: function() { return handleError(function (arg0, arg1) {
4079
+ const ret = arg0.appendChild(arg1);
4080
+ return ret;
4081
+ }, arguments); },
4082
+ __wbg_body_f67922363a220026: function(arg0) {
4083
+ const ret = arg0.body;
4084
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4085
+ },
4086
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
4087
+ const ret = arg0.call(arg1);
4088
+ return ret;
4089
+ }, arguments); },
4090
+ __wbg_createElement_49f60fdcaae809c8: function() { return handleError(function (arg0, arg1, arg2) {
4091
+ const ret = arg0.createElement(getStringFromWasm0(arg1, arg2));
4092
+ return ret;
4093
+ }, arguments); },
4094
+ __wbg_data_d52fd40cc1d7d4e8: function(arg0, arg1) {
4095
+ const ret = arg1.data;
4096
+ const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
4097
+ const len1 = WASM_VECTOR_LEN;
4098
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4099
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4100
+ },
4101
+ __wbg_document_ee35a3d3ae34ef6c: function(arg0) {
4102
+ const ret = arg0.document;
4103
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4104
+ },
4105
+ __wbg_drawImage_00302fc1908197cc: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
4106
+ arg0.drawImage(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
4107
+ }, arguments); },
4108
+ __wbg_drawImage_51b6a9d03c34c5cc: function() { return handleError(function (arg0, arg1, arg2, arg3) {
4109
+ arg0.drawImage(arg1, arg2, arg3);
4110
+ }, arguments); },
4111
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
4112
+ let deferred0_0;
4113
+ let deferred0_1;
4114
+ try {
4115
+ deferred0_0 = arg0;
4116
+ deferred0_1 = arg1;
4117
+ console.error(getStringFromWasm0(arg0, arg1));
4118
+ } finally {
4119
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
4120
+ }
4121
+ },
4122
+ __wbg_getContext_2a5764d48600bc43: function() { return handleError(function (arg0, arg1, arg2) {
4123
+ const ret = arg0.getContext(getStringFromWasm0(arg1, arg2));
4124
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4125
+ }, arguments); },
4126
+ __wbg_getImageData_24d72830c218154d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
4127
+ const ret = arg0.getImageData(arg1, arg2, arg3, arg4);
4128
+ return ret;
4129
+ }, arguments); },
4130
+ __wbg_height_38750dc6de41ee75: function(arg0) {
4131
+ const ret = arg0.height;
4132
+ return ret;
4133
+ },
4134
+ __wbg_height_408f385de046f7e5: function(arg0) {
4135
+ const ret = arg0.height;
4136
+ return ret;
4137
+ },
4138
+ __wbg_height_87250db2be5164b9: function(arg0) {
4139
+ const ret = arg0.height;
4140
+ return ret;
4141
+ },
4142
+ __wbg_instanceof_CanvasRenderingContext2d_4bb052fd1c3d134d: function(arg0) {
4143
+ let result;
4144
+ try {
4145
+ result = arg0 instanceof CanvasRenderingContext2D;
4146
+ } catch (_) {
4147
+ result = false;
4148
+ }
4149
+ const ret = result;
4150
+ return ret;
4151
+ },
4152
+ __wbg_instanceof_HtmlCanvasElement_3f2f6e1edb1c9792: function(arg0) {
4153
+ let result;
4154
+ try {
4155
+ result = arg0 instanceof HTMLCanvasElement;
4156
+ } catch (_) {
4157
+ result = false;
4158
+ }
4159
+ const ret = result;
4160
+ return ret;
4161
+ },
4162
+ __wbg_instanceof_Window_ed49b2db8df90359: function(arg0) {
4163
+ let result;
4164
+ try {
4165
+ result = arg0 instanceof Window;
4166
+ } catch (_) {
4167
+ result = false;
4168
+ }
4169
+ const ret = result;
4170
+ return ret;
4171
+ },
4172
+ __wbg_length_32ed9a279acd054c: function(arg0) {
4173
+ const ret = arg0.length;
4174
+ return ret;
4175
+ },
4176
+ __wbg_new_8a6f238a6ece86ea: function() {
4177
+ const ret = new Error();
4178
+ return ret;
4179
+ },
4180
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
4181
+ const ret = new Uint8Array(arg0);
4182
+ return ret;
4183
+ },
4184
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
4185
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
4186
+ return ret;
4187
+ },
4188
+ __wbg_new_with_u8_clamped_array_and_sh_0c0b789ceb2eab31: function() { return handleError(function (arg0, arg1, arg2, arg3) {
4189
+ const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
4190
+ return ret;
4191
+ }, arguments); },
4192
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
4193
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
4194
+ },
4195
+ __wbg_putImageData_78318465ad96c2c3: function() { return handleError(function (arg0, arg1, arg2, arg3) {
4196
+ arg0.putImageData(arg1, arg2, arg3);
4197
+ }, arguments); },
4198
+ __wbg_set_height_f21f985387070100: function(arg0, arg1) {
4199
+ arg0.height = arg1 >>> 0;
4200
+ },
4201
+ __wbg_set_textContent_3e87dba095d9cdbc: function(arg0, arg1, arg2) {
4202
+ arg0.textContent = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2);
4203
+ },
4204
+ __wbg_set_width_d60bc4f2f20c56a4: function(arg0, arg1) {
4205
+ arg0.width = arg1 >>> 0;
4206
+ },
4207
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
4208
+ const ret = arg1.stack;
4209
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4210
+ const len1 = WASM_VECTOR_LEN;
4211
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4212
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4213
+ },
4214
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
4215
+ const ret = typeof global === 'undefined' ? null : global;
4216
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4217
+ },
4218
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
4219
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
4220
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4221
+ },
4222
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
4223
+ const ret = typeof self === 'undefined' ? null : self;
4224
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4225
+ },
4226
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
4227
+ const ret = typeof window === 'undefined' ? null : window;
4228
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4229
+ },
4230
+ __wbg_width_5901d980713eb80b: function(arg0) {
4231
+ const ret = arg0.width;
4232
+ return ret;
4233
+ },
4234
+ __wbg_width_5f66bde2e810fbde: function(arg0) {
4235
+ const ret = arg0.width;
4236
+ return ret;
4237
+ },
4238
+ __wbg_width_be8f36d66d37751f: function(arg0) {
4239
+ const ret = arg0.width;
4240
+ return ret;
4241
+ },
4242
+ __wbindgen_init_externref_table: function() {
4243
+ const table = wasm.__wbindgen_externrefs;
4244
+ const offset = table.grow(4);
4245
+ table.set(0, undefined);
4246
+ table.set(offset + 0, undefined);
4247
+ table.set(offset + 1, null);
4248
+ table.set(offset + 2, true);
4249
+ table.set(offset + 3, false);
4250
+ },
4251
+ };
4252
+ return {
4253
+ __proto__: null,
4254
+ "./photon_rs_bg.js": import0,
4255
+ };
4256
+ }
4257
+
4258
+ const PhotonImageFinalization = (typeof FinalizationRegistry === 'undefined')
4259
+ ? { register: () => {}, unregister: () => {} }
4260
+ : new FinalizationRegistry(ptr => wasm.__wbg_photonimage_free(ptr >>> 0, 1));
4261
+ const RgbFinalization = (typeof FinalizationRegistry === 'undefined')
4262
+ ? { register: () => {}, unregister: () => {} }
4263
+ : new FinalizationRegistry(ptr => wasm.__wbg_rgb_free(ptr >>> 0, 1));
4264
+ const RgbaFinalization = (typeof FinalizationRegistry === 'undefined')
4265
+ ? { register: () => {}, unregister: () => {} }
4266
+ : new FinalizationRegistry(ptr => wasm.__wbg_rgba_free(ptr >>> 0, 1));
4267
+
4268
+ function addToExternrefTable0(obj) {
4269
+ const idx = wasm.__externref_table_alloc();
4270
+ wasm.__wbindgen_externrefs.set(idx, obj);
4271
+ return idx;
4272
+ }
4273
+
4274
+ function _assertClass(instance, klass) {
4275
+ if (!(instance instanceof klass)) {
4276
+ throw new Error(`expected instance of ${klass.name}`);
4277
+ }
4278
+ }
4279
+
4280
+ function debugString(val) {
4281
+ // primitive types
4282
+ const type = typeof val;
4283
+ if (type == 'number' || type == 'boolean' || val == null) {
4284
+ return `${val}`;
4285
+ }
4286
+ if (type == 'string') {
4287
+ return `"${val}"`;
4288
+ }
4289
+ if (type == 'symbol') {
4290
+ const description = val.description;
4291
+ if (description == null) {
4292
+ return 'Symbol';
4293
+ } else {
4294
+ return `Symbol(${description})`;
4295
+ }
4296
+ }
4297
+ if (type == 'function') {
4298
+ const name = val.name;
4299
+ if (typeof name == 'string' && name.length > 0) {
4300
+ return `Function(${name})`;
4301
+ } else {
4302
+ return 'Function';
4303
+ }
4304
+ }
4305
+ // objects
4306
+ if (Array.isArray(val)) {
4307
+ const length = val.length;
4308
+ let debug = '[';
4309
+ if (length > 0) {
4310
+ debug += debugString(val[0]);
4311
+ }
4312
+ for(let i = 1; i < length; i++) {
4313
+ debug += ', ' + debugString(val[i]);
4314
+ }
4315
+ debug += ']';
4316
+ return debug;
4317
+ }
4318
+ // Test for built-in
4319
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
4320
+ let className;
4321
+ if (builtInMatches && builtInMatches.length > 1) {
4322
+ className = builtInMatches[1];
4323
+ } else {
4324
+ // Failed to match the standard '[object ClassName]'
4325
+ return toString.call(val);
4326
+ }
4327
+ if (className == 'Object') {
4328
+ // we're a user defined class or Object
4329
+ // JSON.stringify avoids problems with cycles, and is generally much
4330
+ // easier than looping through ownProperties of `val`.
4331
+ try {
4332
+ return 'Object(' + JSON.stringify(val) + ')';
4333
+ } catch (_) {
4334
+ return 'Object';
4335
+ }
4336
+ }
4337
+ // errors
4338
+ if (val instanceof Error) {
4339
+ return `${val.name}: ${val.message}\n${val.stack}`;
4340
+ }
4341
+ // TODO we could test for more things here, like `Set`s and `Map`s.
4342
+ return className;
4343
+ }
4344
+
4345
+ function getArrayU8FromWasm0(ptr, len) {
4346
+ ptr = ptr >>> 0;
4347
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
4348
+ }
4349
+
4350
+ function getClampedArrayU8FromWasm0(ptr, len) {
4351
+ ptr = ptr >>> 0;
4352
+ return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
4353
+ }
4354
+
4355
+ let cachedDataViewMemory0 = null;
4356
+ function getDataViewMemory0() {
4357
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
4358
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
4359
+ }
4360
+ return cachedDataViewMemory0;
4361
+ }
4362
+
4363
+ function getStringFromWasm0(ptr, len) {
4364
+ ptr = ptr >>> 0;
4365
+ return decodeText(ptr, len);
4366
+ }
4367
+
4368
+ let cachedUint8ArrayMemory0 = null;
4369
+ function getUint8ArrayMemory0() {
4370
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
4371
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
4372
+ }
4373
+ return cachedUint8ArrayMemory0;
4374
+ }
4375
+
4376
+ let cachedUint8ClampedArrayMemory0 = null;
4377
+ function getUint8ClampedArrayMemory0() {
4378
+ if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) {
4379
+ cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
4380
+ }
4381
+ return cachedUint8ClampedArrayMemory0;
4382
+ }
4383
+
4384
+ function handleError(f, args) {
4385
+ try {
4386
+ return f.apply(this, args);
4387
+ } catch (e) {
4388
+ const idx = addToExternrefTable0(e);
4389
+ wasm.__wbindgen_exn_store(idx);
4390
+ }
4391
+ }
4392
+
4393
+ function isLikeNone(x) {
4394
+ return x === undefined || x === null;
4395
+ }
4396
+
4397
+ function passArray8ToWasm0(arg, malloc) {
4398
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
4399
+ getUint8ArrayMemory0().set(arg, ptr / 1);
4400
+ WASM_VECTOR_LEN = arg.length;
4401
+ return ptr;
4402
+ }
4403
+
4404
+ function passStringToWasm0(arg, malloc, realloc) {
4405
+ if (realloc === undefined) {
4406
+ const buf = cachedTextEncoder.encode(arg);
4407
+ const ptr = malloc(buf.length, 1) >>> 0;
4408
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
4409
+ WASM_VECTOR_LEN = buf.length;
4410
+ return ptr;
4411
+ }
4412
+
4413
+ let len = arg.length;
4414
+ let ptr = malloc(len, 1) >>> 0;
4415
+
4416
+ const mem = getUint8ArrayMemory0();
4417
+
4418
+ let offset = 0;
4419
+
4420
+ for (; offset < len; offset++) {
4421
+ const code = arg.charCodeAt(offset);
4422
+ if (code > 0x7F) break;
4423
+ mem[ptr + offset] = code;
4424
+ }
4425
+ if (offset !== len) {
4426
+ if (offset !== 0) {
4427
+ arg = arg.slice(offset);
4428
+ }
4429
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
4430
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
4431
+ const ret = cachedTextEncoder.encodeInto(arg, view);
4432
+
4433
+ offset += ret.written;
4434
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
4435
+ }
4436
+
4437
+ WASM_VECTOR_LEN = offset;
4438
+ return ptr;
4439
+ }
4440
+
4441
+ function takeFromExternrefTable0(idx) {
4442
+ const value = wasm.__wbindgen_externrefs.get(idx);
4443
+ wasm.__externref_table_dealloc(idx);
4444
+ return value;
4445
+ }
4446
+
4447
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
4448
+ cachedTextDecoder.decode();
4449
+ function decodeText(ptr, len) {
4450
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
4451
+ }
4452
+
4453
+ const cachedTextEncoder = new TextEncoder();
4454
+
4455
+ let WASM_VECTOR_LEN = 0;
4456
+
4457
+ // Decode base64 WASM (works in both dev and compiled binary)
4458
+ const wasmBytes = Uint8Array.from(atob(wasmBase64), c => c.charCodeAt(0));
4459
+ const wasmInstantiated = await WebAssembly.instantiate(wasmBytes, __wbg_get_imports());
4460
+ const wasm = wasmInstantiated.instance.exports;
4461
+ wasm.__wbindgen_start();