From 03cfbd81d4fda7f598ce6c2cfc8501496b169a07 Mon Sep 17 00:00:00 2001 From: can1357 Date: Mon, 19 Jan 2026 00:02:12 +0100 Subject: [PATCH] feat(coding-agent): added vendored photon WASM for image processing - Replaced external photon-node dependency with vendored WebAssembly implementation. - Added local photon library with 200+ image processing functions and WASM bindings. - Updated image conversion and resize utilities to use local photon implementation. - Added error handling for unknown OAuth providers in AI package. --- .gitattributes | 1 + biome.json | 1 + bun.lock | 3 - packages/ai/CHANGELOG.md | 3 + packages/ai/src/cli.ts | 3 + packages/coding-agent/CHANGELOG.md | 4 + packages/coding-agent/package.json | 1 - .../coding-agent/src/utils/image-convert.ts | 2 +- .../coding-agent/src/utils/image-resize.ts | 4 +- .../coding-agent/src/vendor/photon/LICENSE.md | 201 + .../coding-agent/src/vendor/photon/README.md | 158 + .../coding-agent/src/vendor/photon/index.d.ts | 3013 +++++++++++ .../coding-agent/src/vendor/photon/index.js | 4459 +++++++++++++++++ .../src/vendor/photon/photon_rs_bg.wasm | 3 + .../src/vendor/photon/photon_rs_bg.wasm.d.ts | 193 + 15 files changed, 8042 insertions(+), 7 deletions(-) create mode 100644 .gitattributes create mode 100644 packages/coding-agent/src/vendor/photon/LICENSE.md create mode 100644 packages/coding-agent/src/vendor/photon/README.md create mode 100644 packages/coding-agent/src/vendor/photon/index.d.ts create mode 100644 packages/coding-agent/src/vendor/photon/index.js create mode 100644 packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm create mode 100644 packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm.d.ts diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..a9336a01b --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.wasm filter=lfs diff=lfs merge=lfs -text diff --git a/biome.json b/biome.json index 4604c58e1..8ca064def 100644 --- a/biome.json +++ b/biome.json @@ -35,6 +35,7 @@ "files": { "includes": [ "packages/*/src/**/*.ts", + "!**/vendor/**/*", "packages/*/test/**/*.ts", "packages/coding-agent/examples/**/*.ts", "packages/web-ui/src/**/*.ts", diff --git a/bun.lock b/bun.lock index 2c701ab08..b92ebbffb 100644 --- a/bun.lock +++ b/bun.lock @@ -70,7 +70,6 @@ "@oh-my-pi/pi-git-tool": "workspace:*", "@oh-my-pi/pi-tui": "workspace:*", "@openai/agents": "^0.3.7", - "@silvia-odwyer/photon-node": "^0.3.4", "@sinclair/typebox": "^0.34.46", "ajv": "^8.17.1", "chalk": "^5.5.0", @@ -368,8 +367,6 @@ "@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.55.1", "", { "os": "win32", "cpu": "x64" }, "sha512-SPEpaL6DX4rmcXtnhdrQYgzQ5W2uW3SCJch88lB2zImhJRhIIK44fkUrgIV/Q8yUNfw5oyZ5vkeQsZLhCb06lw=="], - "@silvia-odwyer/photon-node": ["@silvia-odwyer/photon-node@0.3.4", "", {}, "sha512-bnly4BKB3KDTFxrUIcgCLbaeVVS8lrAkri1pEzskpmxu9MdfGQTy8b8EgcD83ywD3RPMsIulY8xJH5Awa+t9fA=="], - "@sinclair/typebox": ["@sinclair/typebox@0.34.47", "", {}, "sha512-ZGIBQ+XDvO5JQku9wmwtabcVTHJsgSWAHYtVuM9pBNNR5E88v6Jcj/llpmsjivig5X8A8HHOb4/mbEKPS5EvAw=="], "@smithy/abort-controller": ["@smithy/abort-controller@4.2.8", "", { "dependencies": { "@smithy/types": "^4.12.0", "tslib": "^2.6.2" } }, "sha512-peuVfkYHAmS5ybKxWcfraK7WBBP0J+rkfUcbHJJKQ4ir3UAUNQI+Y4Vt/PqSzGqgloJ5O1dk7+WzNL8wcCSXbw=="], diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 66d481079..192315987 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## [Unreleased] +### Fixed + +- Added error handling for unknown OAuth providers ## [5.6.77] - 2026-01-18 ### Fixed diff --git a/packages/ai/src/cli.ts b/packages/ai/src/cli.ts index c1c226b87..94405d1e7 100755 --- a/packages/ai/src/cli.ts +++ b/packages/ai/src/cli.ts @@ -98,6 +98,9 @@ async function login(provider: OAuthProvider): Promise { onProgress: (msg) => console.log(msg), }); break; + + default: + throw new Error(`Unknown provider: ${provider}`); } const auth = loadAuth(); diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 4985063c3..e0bdcc80a 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## [Unreleased] +### Changed + +- Replaced external photon-node dependency with vendored WebAssembly implementation +- Updated image processing to use local photon library for better performance ## [5.6.70] - 2026-01-18 ### Added diff --git a/packages/coding-agent/package.json b/packages/coding-agent/package.json index cb1c5a270..efdb9ba24 100644 --- a/packages/coding-agent/package.json +++ b/packages/coding-agent/package.json @@ -44,7 +44,6 @@ "@oh-my-pi/pi-git-tool": "workspace:*", "@oh-my-pi/pi-tui": "workspace:*", "@openai/agents": "^0.3.7", - "@silvia-odwyer/photon-node": "^0.3.4", "@sinclair/typebox": "^0.34.46", "ajv": "^8.17.1", "chalk": "^5.5.0", diff --git a/packages/coding-agent/src/utils/image-convert.ts b/packages/coding-agent/src/utils/image-convert.ts index 590dcaf59..897678ecf 100644 --- a/packages/coding-agent/src/utils/image-convert.ts +++ b/packages/coding-agent/src/utils/image-convert.ts @@ -1,4 +1,4 @@ -import photon from "@silvia-odwyer/photon-node"; +import * as photon from "../vendor/photon"; /** * Convert image to PNG format for terminal display. diff --git a/packages/coding-agent/src/utils/image-resize.ts b/packages/coding-agent/src/utils/image-resize.ts index 1a8aaf45f..2d4085553 100644 --- a/packages/coding-agent/src/utils/image-resize.ts +++ b/packages/coding-agent/src/utils/image-resize.ts @@ -1,5 +1,5 @@ import type { ImageContent } from "@oh-my-pi/pi-ai"; -import photon from "@silvia-odwyer/photon-node"; +import * as photon from "../vendor/photon"; export interface ImageResizeOptions { maxWidth?: number; // Default: 2000 @@ -94,7 +94,7 @@ export async function resizeImage(img: ImageContent, options?: ImageResizeOption height: number, jpegQuality: number, ): { buffer: Uint8Array; mimeType: string } { - const resized = photon.resize(image!, width, height, photon.SamplingFilter.Lanczos3); + const resized = photon!.resize(image!, width, height, photon!.SamplingFilter.Lanczos3); try { const pngBuffer = resized.get_bytes(); diff --git a/packages/coding-agent/src/vendor/photon/LICENSE.md b/packages/coding-agent/src/vendor/photon/LICENSE.md new file mode 100644 index 000000000..1b16a2f72 --- /dev/null +++ b/packages/coding-agent/src/vendor/photon/LICENSE.md @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2023, Silvia O'Dwyer + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/coding-agent/src/vendor/photon/README.md b/packages/coding-agent/src/vendor/photon/README.md new file mode 100644 index 000000000..fdad5a5cc --- /dev/null +++ b/packages/coding-agent/src/vendor/photon/README.md @@ -0,0 +1,158 @@ +

+ + Photon banner, showing the Photon logo on a dark background +

+ +
+ + [![Status](https://img.shields.io/badge/status-active-success.svg)]() + [![GitHub Issues](https://img.shields.io/github/issues/silvia-odwyer/photon.svg)](https://github.com/silvia-odwyer/photon/issues) + [![GitHub Pull Requests](https://img.shields.io/github/issues-pr/silvia-odwyer/photon.svg)](https://github.com/silvia-odwyer/p/pulls) + [![Gitter chat](https://badges.gitter.im/silvia-odwyer/photon.png)](https://gitter.im/photonlibrary/community "Gitter chat") + [![Crates.io](https://img.shields.io/crates/v/photon-rs)](https://crates.io/crates/photon-rs) + +
+ +--- + +

High-performance, cross-platform Rust/WebAssembly image processing library +
+

+ +## 📝 Table of Contents +- [Get Started with WebAssembly](https://github.com/silvia-odwyer/photon#-get-started-with-webassembly) +- [Get Started Natively](https://github.com/silvia-odwyer/photon#getting-started) +- [Documentation](https://docs.rs/photon-rs/0.1.0/) +- [Official Website.](https://silvia-odwyer.github.io/photon/) +- [All Available Functions.](https://silvia-odwyer.github.io/photon/docs/photon/all.html) +- [Got Questions? Ask Here!](https://github.com/silvia-odwyer/photon#got-questions) + +Photon is a high-performance Rust image processing library, which compiles to WebAssembly, allowing for +safe, blazing-fast image processing both natively and on the web. + +### Features +- **Fast:** Photon outperforms even the fastest of libraries, including ImageMagick. On the web, its high-performance allows for near-native-speed image processing on the web. Benchmarks coming soon. +- **Call with JS:** Want to use Photon on the web or with Node? Using a simple npm package, you're good to go. Get all the benefits of WebAssembly +with zero-cost abstraction. +- **Use Natively:** For command-line apps, native photo editing apps, and so forth, Photon's core codebase is in Rust, allowing for cross-platform +development. + +### Live Demo +View the [official demo of WASM in action](https://silvia-odwyer.github.io/photon/demo.html). + +### Get Started +#### Getting Started Guide +Check out Photon's [getting started guide, complete with tutorials, installation instructions, and more](https://silvia-odwyer.github.io/photon/guide) + +#### Documentation +### 📚 Documentation +View the [official documentation](https://docs.rs/photon-rs/). + +### Photon In Action + +![Imgur](https://i.imgur.com/PShSZ6k.png) + +### Functionality +96+ customisable functions are available. + +Resize, transform, correct, and filter images: apply as many effects as desired. + +Functions include: +- **Image correction**: Hue rotation, sharpening, brightness adjustment, adjusting saturation, lightening/darkening all within various colour spaces. +- **Convolutions**: Sobel filters, blurs, Laplace effects, edge detection, etc., +- **Channel manipulation**: Increasing/decreasing RGB channel values, swapping channels, removing channels, etc. +- **Transform**: Resize, crop, rotate and flip images. +- **Monochrome effects**: Duotoning, greyscaling of various forms, thresholding, sepia, averaging RGB values +- **Colour manipulation**: Work with the image in various colour spaces such as HSL, LCh, and sRGB, and adjust the colours accordingly. +- **Filters**: Over 30 pre-set filters available, incorporating various effects and transformations. +- **Text**: Apply text to imagery in artistic ways, or to watermark, etc., +- **Watermarking**: Watermark images in multiple formats. +- **Blending**: Blend images together using 10 different techniques, change image backgrounds. + +## Install +### Native +Add the following line to the dependencies section of your Rust project's Cargo.toml: + +###### Cargo.toml +```toml +[dependencies] +photon-rs = "0.3.2" +``` + +### Web +Install Photon as an npm module: + +```bash +npm install --save @silvia-odwyer/photon +``` + +### Node.JS +To install Photon as an npm module for Node.JS use: + +```bash +npm install --save @silvia-odwyer/photon-node +``` + +#### Using Photon Natively +The following code opens an image from the filesystem, applies an effect, and saves it. + +Here is a code sample to get you started: + +```rs +extern crate photon_rs; +use photon_rs::native::{open_image, save_image}; + +fn main() { + // Open the image (a PhotonImage is returned) + let mut img = open_image("test_image.png"); + + // Increment the red channel by 40 + photon_rs::channels::alter_red_channel(&mut img, 40); + + // Write file to filesystem. + save_image(img, "raw_image.jpg"); + +} +``` + +[For more examples, check out the guide on how to get started with Photon natively.](https://silvia-odwyer.github.io/photon/guide/using-photon-natively/) + +#### Using Photon On The Web + +## Modules +Photon contains a series of modules, which include: + +- `effects`: Various image effects, including adding offsets, thresholding, duotoning, solarization, etc., +- `channels`: Functions related to increasing/decreasing the red, green, and blue channels of the image data. +- `transform`: Resize, crop, flip, and rotate images. +- `filters`: Preset filters, which alter the RGB channels of the image. Contains over 20. +- `conv`: Laplace, Sobel, emboss; image proc functions which require image convolution. +- `noise`: Noise generation of varying tints and hues. +- `multiple`: A module for dealing with multiple images, such as watermarking images, etc., +- `correction`: Hue rotation, adjusting saturation, lightening/darkening: all techniques available in multiple colour spaces, which lead to varying effects. + +All effects and filters can be viewed below and on the official website. + +### Run Examples +Clone this crate's official GitHub repo: +```sh +git clone https://github.com/silvia-odwyer/photon +``` + +Run the binary, which will perform an image processing function on an image: +```sh +cd crate +cargo run --release +``` + +Compare the original image with the outputted image, and you'll see the desired effect has been applied. + +### Got Questions? +If you'd like to chat to the developer about your potential use case, or have further questions about this library, +just submit them here, and I'll get back to you! + +- [Spectrum Chat](https://spectrum.chat/photonlibrary) +- [Gitter](https://gitter.im/photonlibrary/community) + +## License +This project is licensed under the Apache 2.0 License - see the [LICENSE.md](LICENSE.md) file for details. \ No newline at end of file diff --git a/packages/coding-agent/src/vendor/photon/index.d.ts b/packages/coding-agent/src/vendor/photon/index.d.ts new file mode 100644 index 000000000..02868b3a7 --- /dev/null +++ b/packages/coding-agent/src/vendor/photon/index.d.ts @@ -0,0 +1,3013 @@ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Provides the image's height, width, and contains the image's raw pixels. + * For use when communicating between JS and WASM, and also natively. + */ +export class PhotonImage { + free(): void; + [Symbol.dispose](): void; + /** + * Convert the PhotonImage to base64. + */ + get_base64(): string; + /** + * Convert the PhotonImage to raw bytes. Returns PNG. + */ + get_bytes(): Uint8Array; + /** + * Convert the PhotonImage to raw bytes. Returns a JPEG. + */ + get_bytes_jpeg(quality: number): Uint8Array; + /** + * Convert the PhotonImage to raw bytes. Returns a WEBP. + */ + get_bytes_webp(): Uint8Array; + /** + * Calculates estimated filesize and returns number of bytes + */ + get_estimated_filesize(): bigint; + /** + * Get the height of the PhotonImage. + */ + get_height(): number; + /** + * Convert the PhotonImage's raw pixels to JS-compatible ImageData. + */ + get_image_data(): ImageData; + /** + * Get the PhotonImage's pixels as a Vec of u8s. + */ + get_raw_pixels(): Uint8Array; + /** + * Get the width of the PhotonImage. + */ + get_width(): number; + /** + * Create a new PhotonImage from a Vec of u8s, which represent raw pixels. + */ + constructor(raw_pixels: Uint8Array, width: number, height: number); + /** + * Create a new PhotonImage from a base64 string. + */ + static new_from_base64(base64: string): PhotonImage; + /** + * Create a new PhotonImage from a Blob/File. + */ + static new_from_blob(blob: Blob): PhotonImage; + /** + * Create a new PhotonImage from a byteslice. + */ + static new_from_byteslice(vec: Uint8Array): PhotonImage; + /** + * Create a new PhotonImage from a HTMLImageElement + */ + static new_from_image(image: HTMLImageElement): PhotonImage; + /** + * Convert ImageData to raw pixels, and update the PhotonImage's raw pixels to this. + */ + set_imgdata(img_data: ImageData): void; +} + +/** + * RGB color type. + */ +export class Rgb { + free(): void; + [Symbol.dispose](): void; + /** + * Get the Blue value. + */ + get_blue(): number; + /** + * Get the Green value. + */ + get_green(): number; + /** + * Get the Red value. + */ + get_red(): number; + /** + * Create a new RGB struct. + */ + constructor(r: number, g: number, b: number); + /** + * Set the Blue value. + */ + set_blue(b: number): void; + /** + * Get the Green value. + */ + set_green(g: number): void; + /** + * Set the Red value. + */ + set_red(r: number): void; +} + +/** + * RGBA color type. + */ +export class Rgba { + free(): void; + [Symbol.dispose](): void; + /** + * Get the alpha value for this color. + */ + get_alpha(): number; + /** + * Get the Blue value. + */ + get_blue(): number; + /** + * Get the Green value. + */ + get_green(): number; + /** + * Get the Red value. + */ + get_red(): number; + /** + * Create a new RGBA struct. + */ + constructor(r: number, g: number, b: number, a: number); + /** + * Set the alpha value. + */ + set_alpha(a: number): void; + /** + * Set the Blue value. + */ + set_blue(b: number): void; + /** + * Get the Green value. + */ + set_green(g: number): void; + /** + * Set the Red value. + */ + set_red(r: number): void; +} + +export enum SamplingFilter { + Nearest = 1, + Triangle = 2, + CatmullRom = 3, + Gaussian = 4, + Lanczos3 = 5, +} + +/** + * Add randomized noise to an image. + * This function adds a Gaussian Noise Sample to each pixel through incrementing each channel by a randomized offset. + * This randomized offset is generated by creating a randomized thread pool. + * **[WASM SUPPORT IS AVAILABLE]**: Randomized thread pools cannot be created with WASM, but + * a workaround using js_sys::Math::random works now. + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example: + * use photon_rs::native::open_image; + * use photon_rs::noise::add_noise_rand; + * use photon_rs::PhotonImage; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * add_noise_rand(&mut img); + * ``` + */ +export function add_noise_rand(photon_image: PhotonImage): void; + +/** + * Adjust the brightness of an image by a factor. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `brightness` - A u8 to add or subtract to the brightness. To increase + * the brightness, pass a positive number (up to 255). To decrease the brightness, + * pass a negative number instead. + * # Example + * + * ```no_run + * use photon_rs::effects::adjust_brightness; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * adjust_brightness(&mut img, 10_i16); + * ``` + */ +export function adjust_brightness(photon_image: PhotonImage, brightness: number): void; + +/** + * Adjust the contrast of an image by a factor. + * + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * * `contrast` - An f32 factor used to adjust contrast. Between [-255.0, 255.0]. The algorithm will + * clamp results if passed factor is out of range. + * # Example + * + * ```no_run + * use photon_rs::effects::adjust_contrast; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * adjust_contrast(&mut img, 30_f32); + * ``` + */ +export function adjust_contrast(photon_image: PhotonImage, contrast: number): void; + +/** + * Increment or decrement every pixel's Blue channel by a constant. + * + * # Arguments + * * `img` - A PhotonImage. + * * `amt` - The amount to increment or decrement the channel's value by for that pixel. + * + * # Example + * + * ```no_run + * // For example, to increase the Blue channel for all pixels by 10: + * use photon_rs::channels::alter_blue_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_blue_channel(&mut img, 10_i16); + * ``` + */ +export function alter_blue_channel(img: PhotonImage, amt: number): void; + +/** + * Alter a select channel by incrementing or decrementing its value by a constant. + * + * # Arguments + * * `img` - A PhotonImage. + * * `channel` - The channel you wish to alter, it should be either 0, 1 or 2, + * representing R, G, or B respectively. (O=Red, 1=Green, 2=Blue) + * * `amount` - The amount to increment/decrement the channel's value by for that pixel. + * A positive value will increment/decrement the channel's value, a negative value will decrement the channel's value. + * + * ## Example + * + * ```no_run + * // For example, to increase the Red channel for all pixels by 10: + * use photon_rs::channels::alter_channel; + * use photon_rs::native::{open_image}; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_channel(&mut img, 0_usize, 10_i16); + * ``` + * + * Adds a constant to a select R, G, or B channel's value. + * + * ### Decrease a channel's value + * // For example, to decrease the Green channel for all pixels by 20: + * ```no_run + * use photon_rs::channels::alter_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_channel(&mut img, 1_usize, -20_i16); + * ``` + * **Note**: Note the use of a minus symbol when decreasing the channel. + */ +export function alter_channel(img: PhotonImage, channel: number, amt: number): void; + +/** + * Increment all 3 channels' values by adding an amt to each channel per pixel. + * + * # Arguments + * * `img` - A PhotonImage. + * * `r_amt` - The amount to increment/decrement the Red channel by. + * * `g_amt` - The amount to increment/decrement the Green channel by. + * * `b_amt` - The amount to increment/decrement the Blue channel by. + * + * # Example + * + * ```no_run + * // For example, to increase the values of the Red channel by 10, the Green channel by 20, + * // and the Blue channel by 50: + * use photon_rs::channels::alter_channels; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_channels(&mut img, 10_i16, 20_i16, 50_i16); + * ``` + */ +export function alter_channels(img: PhotonImage, r_amt: number, g_amt: number, b_amt: number): void; + +/** + * Increment or decrement every pixel's Green channel by a constant. + * + * # Arguments + * * `img` - A PhotonImage. + * * `amt` - The amount to increment/decrement the channel's value by for that pixel. + * + * # Example + * + * ```no_run + * // For example, to increase the Green channel for all pixels by 20: + * use photon_rs::channels::alter_green_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_green_channel(&mut img, 20_i16); + * ``` + */ +export function alter_green_channel(img: PhotonImage, amt: number): void; + +/** + * Increment or decrement every pixel's Red channel by a constant. + * + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `amt` - The amount to increment or decrement the channel's value by for that pixel. + * + * # Example + * + * ```no_run + * // For example, to increase the Red channel for all pixels by 10: + * use photon_rs::channels::alter_red_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_red_channel(&mut img, 10_i16); + * ``` + */ +export function alter_red_channel(photon_image: PhotonImage, amt: number): void; + +/** + * Increment/decrement two channels' values simultaneously by adding an amt to each channel per pixel. + * + * # Arguments + * * `img` - A PhotonImage. + * * `channel1` - A usize from 0 to 2 that represents either the R, G or B channels. + * * `amt1` - The amount to increment/decrement the channel's value by for that pixel. + * * `channel2` -A usize from 0 to 2 that represents either the R, G or B channels. + * * `amt2` - The amount to increment/decrement the channel's value by for that pixel. + * + * # Example + * + * ```no_run + * // For example, to increase the values of the Red and Blue channels per pixel: + * use photon_rs::channels::alter_two_channels; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_two_channels(&mut img, 0_usize, 10_i16, 2_usize, 20_i16); + * ``` + */ +export function alter_two_channels(img: PhotonImage, channel1: number, amt1: number, channel2: number, amt2: number): void; + +/** + * Apply a gradient to an image. + */ +export function apply_gradient(image: PhotonImage): void; + +/** + * Convert an image to grayscale by setting a pixel's 3 RGB values to the Blue channel's value. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * + * # Example + * + * ```no_run + * use photon_rs::monochrome::b_grayscale; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * b_grayscale(&mut img); + * ``` + */ +export function b_grayscale(photon_image: PhotonImage): void; + +/** + * Convert a base64 string to a PhotonImage. + */ +export function base64_to_image(base64: string): PhotonImage; + +/** + * Convert a base64 string to a Vec of u8s. + */ +export function base64_to_vec(base64: string): Uint8Array; + +/** + * Blend two images together. + * + * The `blend_mode` (3rd param) determines which blending mode to use; change this for varying effects. + * The blend modes available include: `overlay`, `over`, `atop`, `xor`, `plus`, `multiply`, `burn`, + * `difference`, `soft_light`, `screen`, `hard_light`, `dodge`, `exclusion`, `lighten`, `darken` (more to come) + * NOTE: The first image must be smaller than the second image passed as params. + * If the first image were larger than the second, then there would be overflowing pixels which would have no corresponding pixels + * in the second image. + * # Arguments + * * `img` - A DynamicImage that contains a view into the image. + * * `img2` - The 2nd DynamicImage to be blended with the first. + * * `blend_mode` - The blending mode to use. See above for complete list of blend modes available. + * # Example + * + * ```no_run + * // For example, to blend two images with the `multiply` blend mode: + * use photon_rs::multiple::blend; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let img2 = open_image("img2.jpg").expect("File should open"); + * blend(&mut img, &img2, "multiply"); + * ``` + */ +export function blend(photon_image: PhotonImage, photon_image2: PhotonImage, blend_mode: string): void; + +/** + * Apply a box blur effect. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a box blur effect: + * use photon_rs::conv::box_blur; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * box_blur(&mut img); + * ``` + */ +export function box_blur(photon_image: PhotonImage): void; + +/** + * Increased contrast filter effect. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::cali; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * cali(&mut img); + * ``` + */ +export function cali(img: PhotonImage): void; + +/** + * Horizontal strips. Divide an image into a series of equal-width strips, for an artistic effect. Sepcify a color as well. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `num_strips` - The numbder of strips + * * `color` - Color of strips. + * # Example + * + * ```no_run + * // For example, to draw blue horizontal strips on a `PhotonImage`: + * use photon_rs::effects::color_horizontal_strips; + * use photon_rs::native::open_image; + * use photon_rs::Rgb; + * + * let color = Rgb::new(255u8, 0u8, 0u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * color_horizontal_strips(&mut img, 8u8, color); + * ``` + */ +export function color_horizontal_strips(photon_image: PhotonImage, num_strips: number, color: Rgb): void; + +/** + * Vertical strips. Divide an image into a series of equal-width strips, for an artistic effect. Sepcify a color as well. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `num_strips` - The numbder of strips + * * `color` - Color of strips. + * # Example + * + * ```no_run + * // For example, to draw red vertical strips on a `PhotonImage`: + * use photon_rs::effects::color_vertical_strips; + * use photon_rs::native::open_image; + * use photon_rs::Rgb; + * + * let color = Rgb::new(255u8, 0u8, 0u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * color_vertical_strips(&mut img, 8u8, color); + * ``` + */ +export function color_vertical_strips(photon_image: PhotonImage, num_strips: number, color: Rgb): void; + +/** + * Colorizes the green channels of the image. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to colorize an image of type `PhotonImage`: + * use photon_rs::effects::colorize; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * colorize(&mut img); + * ``` + */ +export function colorize(photon_image: PhotonImage): void; + +export function create_gradient(width: number, height: number): PhotonImage; + +/** + * Crop an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to crop an image at (0, 0) to (500, 800) + * use photon_rs::native::{open_image}; + * use photon_rs::transform::crop; + * use photon_rs::PhotonImage; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let cropped_img: PhotonImage = crop(&img, 0_u32, 0_u32, 500_u32, 800_u32); + * // Write the contents of this image in JPG format. + * ``` + */ +export function crop(photon_image: PhotonImage, x1: number, y1: number, x2: number, y2: number): PhotonImage; + +export function crop_img_browser(source_canvas: HTMLCanvasElement, width: number, height: number, left: number, top: number): HTMLCanvasElement; + +/** + * Darken the image by a specified amount in the HSL colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to darken the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Darkening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to darken an image by 10% in the HSL colour space: + * use photon_rs::colour_spaces::darken_hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * darken_hsl(&mut img, 0.1_f32); + * ``` + */ +export function darken_hsl(img: PhotonImage, level: number): void; + +/** + * Darken the image by a specified amount in the HSLuv colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to darken the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Darkening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to darken an image by 10% in the HSLuv colour space: + * use photon_rs::colour_spaces::darken_hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * darken_hsluv(&mut img, 0.1_f32); + * ``` + */ +export function darken_hsluv(img: PhotonImage, level: number): void; + +/** + * Darken the image's colours by a specified amount in the HSV colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to darken the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Darkening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to darken an image by 10% in the HSV colour space: + * use photon_rs::colour_spaces::darken_hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * darken_hsv(&mut img, 0.1_f32); + * ``` + */ +export function darken_hsv(img: PhotonImage, level: number): void; + +/** + * Darken the image by a specified amount in the LCh colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to darken the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Darkening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to darken an image by 10% in the LCh colour space: + * use photon_rs::colour_spaces::darken_lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * darken_lch(&mut img, 0.1_f32); + * ``` + */ +export function darken_lch(img: PhotonImage, level: number): void; + +/** + * Decrease the brightness of an image by a constant. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `brightness` - A u8 to subtract from the brightness. It should be a positive number, + * and this value will then be subtracted from the brightness. + * # Example + * + * ```no_run + * use photon_rs::effects::dec_brightness; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * dec_brightness(&mut img, 10_u8); + * ``` + */ +export function dec_brightness(photon_image: PhotonImage, brightness: number): void; + +/** + * Uses a max. decomposition algorithm to convert an image to greyscale. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to decompose an image with max decomposition: + * use photon_rs::monochrome::decompose_max; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * decompose_max(&mut img); + * ``` + */ +export function decompose_max(img: PhotonImage): void; + +/** + * Uses a min. decomposition algorithm to convert an image to greyscale. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to decompose an image with min decomposition: + * use photon_rs::monochrome::decompose_min; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * decompose_min(&mut img); + * ``` + */ +export function decompose_min(img: PhotonImage): void; + +/** + * Desaturate an image by getting the min/max of each pixel's RGB values. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * # Example + * + * ```no_run + * // For example, to desaturate an image: + * use photon_rs::monochrome::desaturate; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * desaturate(&mut img); + * ``` + */ +export function desaturate(img: PhotonImage): void; + +/** + * Desaturate the image by a specified amount in the HSL colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Desaturating by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to desaturate an image by 10% in the LCh colour space: + * use photon_rs::colour_spaces::desaturate_hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * desaturate_hsl(&mut img, 0.1_f32); + * ``` + */ +export function desaturate_hsl(img: PhotonImage, level: number): void; + +/** + * Desaturate the image by a specified amount in the HSLuv colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Desaturating by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to desaturate an image by 10% in the HSLuv colour space: + * use photon_rs::colour_spaces::desaturate_hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * desaturate_hsluv(&mut img, 0.1_f32); + * ``` + */ +export function desaturate_hsluv(img: PhotonImage, level: number): void; + +/** + * Desaturate the image by a specified amount in the HSV colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Desaturating by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to desaturate an image by 10% in the HSV colour space: + * use photon_rs::colour_spaces::desaturate_hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * desaturate_hsv(&mut img, 0.1_f32); + * ``` + */ +export function desaturate_hsv(img: PhotonImage, level: number): void; + +/** + * Desaturate the image by a specified amount in the LCh colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Desaturating by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to desaturate an image by 10% in the LCh colour space: + * use photon_rs::colour_spaces::desaturate_lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * desaturate_lch(&mut img, 0.1_f32); + * ``` + */ +export function desaturate_lch(img: PhotonImage, level: number): void; + +/** + * Detect lines at a 135 degree angle in an image, and highlight these only. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to display the lines at a 135 degree angle in an image: + * use photon_rs::conv::detect_135_deg_lines; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * detect_135_deg_lines(&mut img); + * ``` + */ +export function detect_135_deg_lines(photon_image: PhotonImage): void; + +/** + * Detect lines at a forty five degree angle in an image, and highlight these only. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to display the lines at a forty five degree angle in an image: + * use photon_rs::conv::detect_45_deg_lines; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * detect_45_deg_lines(&mut img); + * ``` + */ +export function detect_45_deg_lines(photon_image: PhotonImage): void; + +/** + * Detect horizontal lines in an image, and highlight these only. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to display the horizontal lines in an image: + * use photon_rs::conv::detect_horizontal_lines; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * detect_horizontal_lines(&mut img); + * ``` + */ +export function detect_horizontal_lines(photon_image: PhotonImage): void; + +/** + * Detect vertical lines in an image, and highlight these only. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to display the vertical lines in an image: + * use photon_rs::conv::detect_vertical_lines; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * detect_vertical_lines(&mut img); + * ``` + */ +export function detect_vertical_lines(photon_image: PhotonImage): void; + +/** + * Applies Floyd-Steinberg dithering to an image. + * Only RGB channels are processed, alpha remains unchanged. + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * * `depth` - bits per channel. Clamped between 1 and 8. + * # Example + * + * ```no_run + * // For example, to turn an image of type `PhotonImage` into a dithered image: + * use photon_rs::effects::dither; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let depth = 1; + * dither(&mut img, depth); + * ``` + */ +export function dither(photon_image: PhotonImage, depth: number): void; + +/** + * Greyscale effect with increased contrast. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::dramatic; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * dramatic(&mut img); + * ``` + */ +export function dramatic(img: PhotonImage): void; + +/** + * Add text to an image. + * The only font available as of now is Roboto. + * Note: A graphic design/text-drawing library is currently being developed, so stay tuned. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `text` - Text string to be drawn to the image. + * * `x` - x-coordinate of where first letter's 1st pixel should be drawn. + * * `y` - y-coordinate of where first letter's 1st pixel should be drawn. + * * `font_size` - Font size in pixels of the text to be drawn. + * + * # Example + * + * ```no_run + * // For example to draw the string "Welcome to Photon!" at 10, 10: + * use photon_rs::native::open_image; + * use photon_rs::text::draw_text; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * draw_text(&mut img, "Welcome to Photon!", 10_i32, 10_i32, 90_f32); + * ``` + */ +export function draw_text(photon_img: PhotonImage, text: string, x: number, y: number, font_size: number): void; + +/** + * Add bordered-text to an image. + * The only font available as of now is Roboto. + * Note: A graphic design/text-drawing library is currently being developed, so stay tuned. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `text` - Text string to be drawn to the image. + * * `x` - x-coordinate of where first letter's 1st pixel should be drawn. + * * `y` - y-coordinate of where first letter's 1st pixel should be drawn. + * * `font_size` - Font size in pixels of the text to be drawn. + * + * # Example + * + * ```no_run + * // For example to draw the string "Welcome to Photon!" at 10, 10: + * use photon_rs::native::open_image; + * use photon_rs::text::draw_text_with_border; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * draw_text_with_border(&mut img, "Welcome to Photon!", 10_i32, 10_i32, 90_f32); + * ``` + */ +export function draw_text_with_border(photon_img: PhotonImage, text: string, x: number, y: number, font_size: number): void; + +export function duotone(photon_image: PhotonImage, color_a: Rgb, color_b: Rgb): void; + +/** + * Duotone effect with purple tones. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::duotone_horizon; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * duotone_horizon(&mut img); + * ``` + */ +export function duotone_horizon(img: PhotonImage): void; + +/** + * Duotone effect with a lilac hue + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::duotone_lilac; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * duotone_lilac(&mut img); + * ``` + */ +export function duotone_lilac(img: PhotonImage): void; + +/** + * A duotone ochre tint effect + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::duotone_ochre; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * duotone_ochre(&mut img); + * ``` + */ +export function duotone_ochre(img: PhotonImage): void; + +/** + * A duotone filter with a user-specified color and a gray color + * + * # Arguments + * * `img` - A PhotonImage. + * * `rgb_color` - RGB color + * # Example + * + * ```no_run + * use photon_rs::filters::duotone_tint; + * use photon_rs::native::open_image; + * use photon_rs::Rgb; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgb_color = Rgb::new(12, 12, 10); + * duotone_tint(&mut img, rgb_color); + * ``` + */ +export function duotone_tint(img: PhotonImage, rgb_color: Rgb): void; + +/** + * Duotone effect with blue and purple tones. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::duotone_violette; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * duotone_violette(&mut img); + * ``` + */ +export function duotone_violette(img: PhotonImage): void; + +/** + * Apply edge detection to an image, to create a dark version with its edges highlighted. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to increase the Red channel for all pixels by 10: + * use photon_rs::conv::edge_detection; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * edge_detection(&mut img); + * ``` + */ +export function edge_detection(photon_image: PhotonImage): void; + +/** + * Preset edge effect. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply this effect: + * use photon_rs::conv::edge_one; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * edge_one(&mut img); + * ``` + */ +export function edge_one(photon_image: PhotonImage): void; + +/** + * Apply an emboss effect to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply an emboss effect: + * use photon_rs::conv::emboss; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * emboss(&mut img); + * ``` + */ +export function emboss(photon_image: PhotonImage): void; + +/** + * Apply a filter to an image. Over 20 filters are available. + * The filters are as follows: + * * **oceanic**: Add an aquamarine-tinted hue to an image. + * * **islands**: Aquamarine tint. + * * **marine**: Add a green/blue mixed hue to an image. + * * **seagreen**: Dark green hue, with tones of blue. + * * **flagblue**: Royal blue tint + * * **liquid**: Blue-inspired tint. + * * **diamante**: Custom filter with a blue/turquoise tint. + * * **radio**: Fallout-style radio effect. + * * **twenties**: Slight-blue tinted historical effect. + * * **rosetint**: Rose-tinted filter. + * * **mauve**: Purple-infused filter. + * * **bluechrome**: Blue monochrome effect. + * * **vintage**: Vintage filter with a red tint. + * * **perfume**: Increase the blue channel, with moderate increases in the Red and Green channels. + * * **serenity**: Custom filter with an increase in the Blue channel's values. + * # Arguments + * * `img` - A PhotonImage. + * * `filter_name` - The filter's name. Choose from the selection above, eg: "oceanic" + * # Example + * + * ```no_run + * // For example, to add a filter called "vintage" to an image: + * use photon_rs::filters::filter; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * filter(&mut img, "vintage"); + * ``` + */ +export function filter(img: PhotonImage, filter_name: string): void; + +/** + * Apply a red hue, with increased contrast and brightness. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::firenze; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * firenze(&mut img); + * ``` + */ +export function firenze(img: PhotonImage): void; + +/** + * Flip an image horizontally. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to flip an image horizontally: + * use photon_rs::native::open_image; + * use photon_rs::transform::fliph; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * fliph(&mut img); + * ``` + */ +export function fliph(photon_image: PhotonImage): void; + +/** + * Flip an image vertically. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to flip an image vertically: + * use photon_rs::native::open_image; + * use photon_rs::transform::flipv; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * flipv(&mut img); + * ``` + */ +export function flipv(photon_image: PhotonImage): void; + +/** + * Turn an image into an frosted glass see through + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to turn an image of type `PhotonImage` into frosted glass see through: + * use photon_rs::effects::frosted_glass; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * frosted_glass(&mut img); + * ``` + */ +export function frosted_glass(photon_image: PhotonImage): void; + +/** + * Convert an image to grayscale by setting a pixel's 3 RGB values to the Green channel's value. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * + * # Example + * + * ```no_run + * use photon_rs::monochrome::g_grayscale; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * g_grayscale(&mut img); + * ``` + */ +export function g_grayscale(photon_image: PhotonImage): void; + +/** + * Applies gamma correction to an image. + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * * `red` - Gamma value for red channel. + * * `green` - Gamma value for green channel. + * * `blue` - Gamma value for blue channel. + * # Example + * + * ```no_run + * // For example, to turn an image of type `PhotonImage` into a gamma corrected image: + * use photon_rs::colour_spaces::gamma_correction; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * gamma_correction(&mut img, 2.2, 2.2, 2.2); + * ``` + */ +export function gamma_correction(photon_image: PhotonImage, red: number, green: number, blue: number): void; + +/** + * Gaussian blur in linear time. + * + * Reference: http://blog.ivank.net/fastest-gaussian-blur.html + * + * # Arguments + * * `photon_image` - A PhotonImage + * * `radius` - blur radius + * # Example + * + * ```no_run + * use photon_rs::conv::gaussian_blur; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * gaussian_blur(&mut img, 3_i32); + * ``` + */ +export function gaussian_blur(photon_image: PhotonImage, radius: number): void; + +/** + * Get the ImageData from a 2D canvas context + */ +export function get_image_data(canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D): ImageData; + +/** + * Apply a vintage, golden hue to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::golden; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * golden(&mut img); + * ``` + */ +export function golden(img: PhotonImage): void; + +/** + * Convert an image to grayscale using the conventional averaging algorithm. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * # Example + * + * ```no_run + * // For example, to convert an image of type `PhotonImage` to grayscale: + * use photon_rs::monochrome::grayscale; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * grayscale(&mut img); + * ``` + */ +export function grayscale(img: PhotonImage): void; + +/** + * Convert an image to grayscale with a human corrected factor, to account for human vision. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * # Example + * + * ```no_run + * // For example, to convert an image of type `PhotonImage` to grayscale with a human corrected factor: + * use photon_rs::monochrome::grayscale_human_corrected; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * grayscale_human_corrected(&mut img); + * ``` + */ +export function grayscale_human_corrected(img: PhotonImage): void; + +/** + * Employ only a limited number of gray shades in an image. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `num_shades` - The number of grayscale shades to be displayed in the image. + * + * # Example + * + * ```no_run + * // For example, to limit an image to four shades of gray only: + * use photon_rs::monochrome::grayscale_shades; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * grayscale_shades(&mut img, 4_u8); + * ``` + */ +export function grayscale_shades(photon_image: PhotonImage, num_shades: number): void; + +/** + * Halftoning effect. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example: + * use photon_rs::effects::halftone; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * halftone(&mut img); + * ``` + */ +export function halftone(photon_image: PhotonImage): void; + +/** + * Horizontal strips. Divide an image into a series of equal-height strips, for an artistic effect. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `num_strips` - The number of strips + * # Example + * + * ```no_run + * // For example, to draw horizontal strips on a `PhotonImage`: + * use photon_rs::effects::horizontal_strips; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * horizontal_strips(&mut img, 8u8); + * ``` + */ +export function horizontal_strips(photon_image: PhotonImage, num_strips: number): void; + +/** + * Image manipulation effects in the HSL colour space. + * + * Effects include: + * * **saturate** - Saturation increase. + * * **desaturate** - Desaturate the image. + * * **shift_hue** - Hue rotation by a specified number of degrees. + * * **darken** - Decrease the brightness. + * * **lighten** - Increase the brightness. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten` + * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by. + * # Example + * ```no_run + * // For example to increase the saturation by 10%: + * use photon_rs::colour_spaces::hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hsl(&mut img, "saturate", 0.1_f32); + * ``` + */ +export function hsl(photon_image: PhotonImage, mode: string, amt: number): void; + +/** + * Image manipulation effects in the HSLuv colour space + * + * Effects include: + * * **saturate** - Saturation increase. + * * **desaturate** - Desaturate the image. + * * **shift_hue** - Hue rotation by a specified number of degrees. + * * **darken** - Decrease the brightness. + * * **lighten** - Increase the brightness. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten` + * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by. + * # Example + * ```no_run + * // For example to increase the saturation by 10%: + * use photon_rs::colour_spaces::hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hsluv(&mut img, "saturate", 0.1_f32); + * ``` + */ +export function hsluv(photon_image: PhotonImage, mode: string, amt: number): void; + +/** + * Image manipulation in the HSV colour space. + * + * Effects include: + * * **saturate** - Saturation increase. + * * **desaturate** - Desaturate the image. + * * **shift_hue** - Hue rotation by a specified number of degrees. + * * **darken** - Decrease the brightness. + * * **lighten** - Increase the brightness. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten` + * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by. + * + * # Example + * ```no_run + * // For example to increase the saturation by 10%: + * use photon_rs::colour_spaces::hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hsv(&mut img, "saturate", 0.1_f32); + * ``` + */ +export function hsv(photon_image: PhotonImage, mode: string, amt: number): void; + +/** + * Shift hue by a specified number of degrees in the HSL colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by. + * + * # Example + * ```no_run + * // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space: + * use photon_rs::colour_spaces::hue_rotate_hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hue_rotate_hsl(&mut img, 120_f32); + * ``` + */ +export function hue_rotate_hsl(img: PhotonImage, degrees: number): void; + +/** + * Shift hue by a specified number of degrees in the HSLuv colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by. + * + * # Example + * ```no_run + * // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space: + * use photon_rs::colour_spaces::hue_rotate_hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hue_rotate_hsluv(&mut img, 120_f32); + * ``` + */ +export function hue_rotate_hsluv(img: PhotonImage, degrees: number): void; + +/** + * Shift hue by a specified number of degrees in the HSV colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by. + * + * # Example + * ```no_run + * // For example to hue rotate/shift the hue by 120 degrees in the HSV colour space: + * use photon_rs::colour_spaces::hue_rotate_hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hue_rotate_hsv(&mut img, 120_f32); + * ``` + */ +export function hue_rotate_hsv(img: PhotonImage, degrees: number): void; + +/** + * Shift hue by a specified number of degrees in the LCh colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by. + * + * # Example + * ```no_run + * // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space: + * use photon_rs::colour_spaces::hue_rotate_lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hue_rotate_lch(&mut img, 120_f32); + * ``` + */ +export function hue_rotate_lch(img: PhotonImage, degrees: number): void; + +/** + * Apply an identity kernel convolution to an image. + * + * # Arguments + * * `img` -A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply an identity kernel convolution: + * use photon_rs::conv::identity; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * identity(&mut img); + * ``` + */ +export function identity(photon_image: PhotonImage): void; + +/** + * Increase the brightness of an image by a constant. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `brightness` - A u8 to add to the brightness. + * # Example + * + * ```no_run + * use photon_rs::effects::inc_brightness; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * inc_brightness(&mut img, 10_u8); + * ``` + */ +export function inc_brightness(photon_image: PhotonImage, brightness: number): void; + +/** + * Invert RGB value of an image. + * + * # Arguments + * * `photon_image` - A DynamicImage that contains a view into the image. + * # Example + * + * ```no_run + * use photon_rs::channels::invert; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * invert(&mut img); + * ``` + */ +export function invert(photon_image: PhotonImage): void; + +/** + * Apply a standard laplace convolution. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a laplace effect: + * use photon_rs::conv::laplace; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * laplace(&mut img); + * ``` + */ +export function laplace(photon_image: PhotonImage): void; + +/** + * Image manipulation effects in the LCh colour space + * + * Effects include: + * * **saturate** - Saturation increase. + * * **desaturate** - Desaturate the image. + * * **shift_hue** - Hue rotation by a specified number of degrees. + * * **darken** - Decrease the brightness. + * * **lighten** - Increase the brightness. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten` + * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by. + * # Example + * ```no_run + * // For example to increase the saturation by 10%: + * use photon_rs::colour_spaces::lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * lch(&mut img, "saturate", 0.1_f32); + * ``` + */ +export function lch(photon_image: PhotonImage, mode: string, amt: number): void; + +/** + * Lighten an image by a specified amount in the HSL colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Lightening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to lighten an image by 10% in the HSL colour space: + * use photon_rs::colour_spaces::lighten_hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * lighten_hsl(&mut img, 0.1_f32); + * ``` + */ +export function lighten_hsl(img: PhotonImage, level: number): void; + +/** + * Lighten an image by a specified amount in the HSLuv colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Lightening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to lighten an image by 10% in the HSLuv colour space: + * use photon_rs::colour_spaces::lighten_hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * lighten_hsluv(&mut img, 0.1_f32); + * ``` + */ +export function lighten_hsluv(img: PhotonImage, level: number): void; + +/** + * Lighten an image by a specified amount in the HSV colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Lightening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to lighten an image by 10% in the HSV colour space: + * use photon_rs::colour_spaces::lighten_hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * lighten_hsv(&mut img, 0.1_f32); + * ``` + */ +export function lighten_hsv(img: PhotonImage, level: number): void; + +/** + * Lighten an image by a specified amount in the LCh colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Lightening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to lighten an image by 10% in the LCh colour space: + * use photon_rs::colour_spaces::lighten_lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * lighten_lch(&mut img, 0.1_f32); + * ``` + */ +export function lighten_lch(img: PhotonImage, level: number): void; + +/** + * Solarization on the Red and Green channels. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::lix; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * lix(&mut img); + * ``` + */ +export function lix(photon_image: PhotonImage): void; + +/** + * Apply a lofi effect to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::lofi; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * lofi(&mut img); + * ``` + */ +export function lofi(img: PhotonImage): void; + +/** + * Mix image with a single color, supporting passing `opacity`. + * The algorithm comes from Jimp. See `function mix` and `function colorFn` at following link: + * https://github.com/oliver-moran/jimp/blob/29679faa597228ff2f20d34c5758e4d2257065a3/packages/plugin-color/src/index.js + * Specifically, result_value = (mix_color_value - origin_value) * opacity + origin_value = + * mix_color_value * opacity + (1 - opacity) * origin_value for each + * of RGB channel. + * + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * * `mix_color` - the color to be mixed in, as an RGB value. + * * `opacity` - the opacity of color when mixed to image. Float value from 0 to 1. + * # Example + * + * ```no_run + * // For example, to mix an image with rgb (50, 255, 254) and opacity 0.4: + * use photon_rs::Rgb; + * use photon_rs::colour_spaces::mix_with_colour; + * use photon_rs::native::open_image; + * + * let mix_colour = Rgb::new(50_u8, 255_u8, 254_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * mix_with_colour(&mut img, mix_colour, 0.4_f32); + * ``` + */ +export function mix_with_colour(photon_image: PhotonImage, mix_colour: Rgb, opacity: number): void; + +/** + * Apply a monochrome effect of a certain colour. + * + * It does so by averaging the R, G, and B values of a pixel, and then adding a + * separate value to that averaged value for each channel to produce a tint. + * # Arguments + * * `photon_image` - A PhotonImage. + * * `r_offset` - The value to add to the Red channel per pixel. + * * `g_offset` - The value to add to the Green channel per pixel. + * * `b_offset` - The value to add to the Blue channel per pixel. + * + * # Example + * + * ```no_run + * // For example, to apply a monochrome effect to an image: + * use photon_rs::monochrome::monochrome; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * monochrome(&mut img, 40_u32, 50_u32, 100_u32); + * ``` + */ +export function monochrome(img: PhotonImage, r_offset: number, g_offset: number, b_offset: number): void; + +/** + * Monochrome tint effect with increased contrast + * + * # Arguments + * * `img` - A PhotonImage. + * * `rgb_color` - RGB color + * # Example + * + * ```no_run + * use photon_rs::filters::monochrome_tint; + * use photon_rs::native::open_image; + * use photon_rs::Rgb; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgb_color = Rgb::new(12, 12, 10); + * monochrome_tint(&mut img, rgb_color); + * ``` + */ +export function monochrome_tint(img: PhotonImage, rgb_color: Rgb): void; + +/** + * Adds multiple offsets to the image by a certain number of pixels (on two channels). + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `offset` - The offset is added to the pixels in the image. + * # Example + * + * ```no_run + * // For example, to add a 30-pixel offset to both the red and blue channels: + * use photon_rs::effects::multiple_offsets; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * multiple_offsets(&mut img, 30_u32, 0_usize, 2_usize); + * ``` + */ +export function multiple_offsets(photon_image: PhotonImage, offset: number, channel_index: number, channel_index2: number): void; + +/** + * Solarization on the Blue channel. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::neue; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * neue(&mut img); + * ``` + */ +export function neue(photon_image: PhotonImage): void; + +/** + * Noise reduction. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to noise reduct an image: + * use photon_rs::conv::noise_reduction; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * noise_reduction(&mut img); + * ``` + * Adds a constant to a select R, G, or B channel's value. + */ +export function noise_reduction(photon_image: PhotonImage): void; + +/** + * Normalizes an image by remapping its range of pixels values. Only RGB + * channels are processed and each channel is stretched to \[0, 255\] range + * independently. This process is also known as contrast stretching. + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to turn an image of type `PhotonImage` into a normalized image: + * use photon_rs::effects::normalize; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * normalize(&mut img); + * ``` + */ +export function normalize(photon_image: PhotonImage): void; + +/** + * Apply a greyscale effect with increased contrast. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::obsidian; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * obsidian(&mut img); + * ``` + */ +export function obsidian(img: PhotonImage): void; + +/** + * Adds an offset to the image by a certain number of pixels. + * + * This creates an RGB shift effect. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `channel_index`: The index of the channel to increment. 0 for red, 1 for green and 2 for blue. + * * `offset` - The offset is added to the pixels in the image. + * # Example + * + * ```no_run + * // For example, to offset pixels by 30 pixels on the red channel: + * use photon_rs::effects::offset; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * offset(&mut img, 0_usize, 30_u32); + * ``` + */ +export function offset(photon_image: PhotonImage, channel_index: number, offset: number): void; + +/** + * Adds an offset to the blue channel by a certain number of pixels. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `offset_amt` - The offset you want to move the blue channel by. + * # Example + * // For example, to add an offset to the green channel by 40 pixels. + * + * ```no_run + * use photon_rs::effects::offset_blue; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * offset_blue(&mut img, 40_u32); + * ``` + */ +export function offset_blue(img: PhotonImage, offset_amt: number): void; + +/** + * Adds an offset to the green channel by a certain number of pixels. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `offset` - The offset you want to move the green channel by. + * # Example + * + * ```no_run + * // For example, to add an offset to the green channel by 30 pixels. + * use photon_rs::effects::offset_green; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * offset_green(&mut img, 30_u32); + * ``` + */ +export function offset_green(img: PhotonImage, offset_amt: number): void; + +/** + * Adds an offset to the red channel by a certain number of pixels. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `offset` - The offset you want to move the red channel by. + * # Example + * + * ```no_run + * // For example, to add an offset to the red channel by 30 pixels. + * use photon_rs::effects::offset_red; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * offset_red(&mut img, 30_u32); + * ``` + */ +export function offset_red(img: PhotonImage, offset_amt: number): void; + +/** + * Turn an image into an oil painting + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `radius` - Radius of each paint particle + * * `intesnity` - How artsy an Image should be + * # Example + * + * ```no_run + * // For example, to oil an image of type `PhotonImage`: + * use photon_rs::effects::oil; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * oil(&mut img, 4i32, 55.0); + * ``` + */ +export function oil(photon_image: PhotonImage, radius: number, intensity: number): void; + +/** + * Convert a HTML5 Canvas Element to a PhotonImage. + * + * This converts the ImageData found in the canvas context to a PhotonImage, + * which can then have effects or filters applied to it. + */ +export function open_image(canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D): PhotonImage; + +/** + * Apply padding on the left side of the PhotonImage + * A padded PhotonImage is returned. + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `padding` - The amount of padding to be applied to the PhotonImage. + * * `padding_rgba` - Tuple containing the RGBA code for padding color. + * + * # Example + * + * ```no_run + * // For example, to apply a padding of 10 pixels on the bottom of a PhotonImage: + * use photon_rs::transform::padding_bottom; + * use photon_rs::native::open_image; + * use photon_rs::Rgba; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8); + * padding_bottom(&img, 10_u32, rgba); + * ``` + */ +export function padding_bottom(img: PhotonImage, padding: number, padding_rgba: Rgba): PhotonImage; + +/** + * Apply padding on the left side of the PhotonImage + * A padded PhotonImage is returned. + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `padding` - The amount of padding to be applied to the PhotonImage. + * * `padding_rgba` - Tuple containing the RGBA code for padding color. + * + * # Example + * + * ```no_run + * // For example, to apply a padding of 10 pixels on the left side of a PhotonImage: + * use photon_rs::transform::padding_left; + * use photon_rs::native::open_image; + * use photon_rs::Rgba; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8); + * padding_left(&img, 10_u32, rgba); + * ``` + */ +export function padding_left(img: PhotonImage, padding: number, padding_rgba: Rgba): PhotonImage; + +/** + * Apply padding on the left side of the PhotonImage + * A padded PhotonImage is returned. + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `padding` - The amount of padding to be applied to the PhotonImage. + * * `padding_rgba` - Tuple containing the RGBA code for padding color. + * + * # Example + * + * ```no_run + * // For example, to apply a padding of 10 pixels on the right side of a PhotonImage: + * use photon_rs::transform::padding_right; + * use photon_rs::native::open_image; + * use photon_rs::Rgba; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8); + * padding_right(&img, 10_u32, rgba); + * ``` + */ +export function padding_right(img: PhotonImage, padding: number, padding_rgba: Rgba): PhotonImage; + +/** + * Apply padding on the left side of the PhotonImage + * A padded PhotonImage is returned. + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `padding` - The amount of padding to be applied to the PhotonImage. + * * `padding_rgba` - Tuple containing the RGBA code for padding color. + * + * # Example + * + * ```no_run + * // For example, to apply a padding of 10 pixels on the top of a PhotonImage: + * use photon_rs::transform::padding_top; + * use photon_rs::native::open_image; + * use photon_rs::Rgba; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8); + * padding_top(&img, 10_u32, rgba); + * ``` + */ +export function padding_top(img: PhotonImage, padding: number, padding_rgba: Rgba): PhotonImage; + +/** + * Apply uniform padding around the PhotonImage + * A padded PhotonImage is returned. + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `padding` - The amount of padding to be applied to the PhotonImage. + * * `padding_rgba` - Tuple containing the RGBA code for padding color. + * + * # Example + * + * ```no_run + * // For example, to apply a padding of 10 pixels around a PhotonImage: + * use photon_rs::transform::padding_uniform; + * use photon_rs::native::open_image; + * use photon_rs::Rgba; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8); + * padding_uniform(&img, 10_u32, rgba); + * ``` + */ +export function padding_uniform(img: PhotonImage, padding: number, padding_rgba: Rgba): PhotonImage; + +/** + * Apply a rose tint to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::pastel_pink; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * pastel_pink(&mut img); + * ``` + */ +export function pastel_pink(img: PhotonImage): void; + +/** + * Add pink-tinted noise to an image. + * + * **[WASM SUPPORT IS AVAILABLE]**: Randomized thread pools cannot be created with WASM, but + * a workaround using js_sys::Math::random works now. + * # Arguments + * * `name` - A PhotonImage that contains a view into the image. + * + * # Example + * + * ```no_run + * // For example, to add pink-tinted noise to an image: + * use photon_rs::native::open_image; + * use photon_rs::noise::pink_noise; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * pink_noise(&mut img); + * ``` + */ +export function pink_noise(photon_image: PhotonImage): void; + +/** + * Pixelize an image. + * + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * * `pixel_size` - Targeted pixel size of generated image. + * # Example + * + * ```no_run + * // For example, to turn an image of type `PhotonImage` into a pixelized image with 50 pixels blocks: + * use photon_rs::effects::pixelize; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * pixelize(&mut img, 50); + * ``` + */ +export function pixelize(photon_image: PhotonImage, pixel_size: number): void; + +/** + * Apply a horizontal Prewitt convolution to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a horizontal Prewitt convolution effect: + * use photon_rs::conv::prewitt_horizontal; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * prewitt_horizontal(&mut img); + * ``` + */ +export function prewitt_horizontal(photon_image: PhotonImage): void; + +/** + * Reduces an image to the primary colours. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to add a primary colour effect to an image of type `DynamicImage`: + * use photon_rs::effects::primary; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * primary(&mut img); + * ``` + */ +export function primary(img: PhotonImage): void; + +/** + * Place a PhotonImage onto a 2D canvas. + */ +export function putImageData(canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D, new_image: PhotonImage): void; + +/** + * Convert an image to grayscale by setting a pixel's 3 RGB values to the Red channel's value. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * + * # Example + * + * ```no_run + * use photon_rs::monochrome::r_grayscale; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * r_grayscale(&mut img); + * ``` + */ +export function r_grayscale(photon_image: PhotonImage): void; + +/** + * Remove the Blue channel's influence in an image. + * + * # Arguments + * * `img` - A PhotonImage. + * * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter. + * + * # Example + * + * ```no_run + * // For example, to remove the blue channel for blue channel pixel values less than 50: + * use photon_rs::channels::remove_blue_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * remove_blue_channel(&mut img, 50_u8); + * ``` + */ +export function remove_blue_channel(img: PhotonImage, min_filter: number): void; + +/** + * Set a certain channel to zero, thus removing the channel's influence in the pixels' final rendered colour. + * + * # Arguments + * * `img` - A PhotonImage. + * * `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. + * * `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 + * 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, + * then channel would be 0 and min_filter would be 50. + * + * # Example + * + * ```no_run + * // For example, to remove the Red channel with a min_filter of 100: + * use photon_rs::channels::remove_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * remove_channel(&mut img, 0_usize, 100_u8); + * ``` + */ +export function remove_channel(img: PhotonImage, channel: number, min_filter: number): void; + +/** + * Remove the Green channel's influence in an image. + * + * # Arguments + * * `img` - A PhotonImage. + * * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter. + * + * # Example + * + * ```no_run + * // For example, to remove the green channel for green channel pixel values less than 50: + * use photon_rs::channels::remove_green_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * remove_green_channel(&mut img, 50_u8); + * ``` + */ +export function remove_green_channel(img: PhotonImage, min_filter: number): void; + +/** + * Remove the Red channel's influence in an image. + * + * # Arguments + * * `img` - A PhotonImage. + * * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter. + * + * # Example + * + * ```no_run + * // For example, to remove the red channel for red channel pixel values less than 50: + * use photon_rs::channels::remove_red_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * remove_red_channel(&mut img, 50_u8); + * ``` + */ +export function remove_red_channel(img: PhotonImage, min_filter: number): void; + +/** + * Resample the PhotonImage. + * + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `dst_width` - Target width. + * * `dst_height` - Target height. + * + * # Example + * + * ```no_run + * // For example, to resample a PhotonImage to 1920x1080 size: + * use photon_rs::native::open_image; + * use photon_rs::transform::resample; + * + * let img = open_image("img.jpg").expect("File should open"); + * let rotated_img = resample(&img, 1920, 1080); + * ``` + */ +export function resample(img: PhotonImage, dst_width: number, dst_height: number): PhotonImage; + +/** + * Resize an image. + * + * # Arguments + * * `img` - A PhotonImage. + * * `width` - New width. + * * `height` - New height. + * * `sampling_filter` - Nearest = 1, Triangle = 2, CatmullRom = 3, Gaussian = 4, Lanczos3 = 5 + */ +export function resize(photon_img: PhotonImage, width: number, height: number, sampling_filter: SamplingFilter): PhotonImage; + +/** + * Resize an image on the web. + * + * # Arguments + * * `img` - A PhotonImage. + * * `width` - New width. + * * `height` - New height. + * * `sampling_filter` - Nearest = 1, Triangle = 2, CatmullRom = 3, Gaussian = 4, Lanczos3 = 5 + */ +export function resize_img_browser(photon_img: PhotonImage, width: number, height: number, sampling_filter: SamplingFilter): HTMLCanvasElement; + +/** + * Rotate the PhotonImage on an arbitrary angle + * A rotated PhotonImage is returned. + * + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `angle` - Rotation angle in degrees. + * + * # Example + * + * ```no_run + * // For example, to rotate a PhotonImage by 30 degrees: + * use photon_rs::native::open_image; + * use photon_rs::transform::rotate; + * + * let img = open_image("img.jpg").expect("File should open"); + * let rotated_img = rotate(&img, 30.0); + * ``` + */ +export function rotate(photon_img: PhotonImage, angle: number): PhotonImage; + +/** + * ! [temp] Check if WASM is supported. + */ +export function run(): void; + +/** + * Solarization on the Red and Blue channels. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::ryo; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * ryo(&mut img); + * ``` + */ +export function ryo(photon_image: PhotonImage): void; + +/** + * Increase the image's saturation by converting each pixel's colour to the HSL colour space + * and increasing the colour's saturation. + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Increasing saturation by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to increase saturation by 10% in the HSL colour space: + * use photon_rs::colour_spaces::saturate_hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * saturate_hsl(&mut img, 0.1_f32); + * ``` + */ +export function saturate_hsl(img: PhotonImage, level: number): void; + +/** + * Increase the image's saturation in the HSLuv colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Increasing saturation by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to increase saturation by 40% in the HSLuv colour space: + * use photon_rs::colour_spaces::saturate_hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * saturate_hsluv(&mut img, 0.4_f32); + * ``` + */ +export function saturate_hsluv(img: PhotonImage, level: number): void; + +/** + * Increase the image's saturation in the HSV colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level by which to increase the saturation by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Increasing saturation by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to increase saturation by 30% in the HSV colour space: + * use photon_rs::colour_spaces::saturate_hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * saturate_hsv(&mut img, 0.3_f32); + * ``` + */ +export function saturate_hsv(img: PhotonImage, level: number): void; + +/** + * Increase the image's saturation in the LCh colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Increasing saturation by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to increase saturation by 40% in the Lch colour space: + * use photon_rs::colour_spaces::saturate_lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * saturate_lch(&mut img, 0.4_f32); + * ``` + */ +export function saturate_lch(img: PhotonImage, level: number): void; + +/** + * Resize image using seam carver. + * Resize only if new dimensions are smaller, than original image. + * # NOTE: This is still experimental feature, and pretty slow. + * + * # Arguments + * * `img` - A PhotonImage. + * * `width` - New width. + * * `height` - New height. + * + * # Example + * + * ```no_run + * // For example, resize image using seam carver: + * use photon_rs::native::open_image; + * use photon_rs::transform::seam_carve; + * use photon_rs::PhotonImage; + * + * let img = open_image("img.jpg").expect("File should open"); + * let result: PhotonImage = seam_carve(&img, 100_u32, 100_u32); + * ``` + */ +export function seam_carve(img: PhotonImage, width: number, height: number): PhotonImage; + +/** + * Selectively change pixel colours which are similar to the reference colour provided. + * + * Similarity between two colours is calculated via the CIE76 formula. + * Only changes the color of a pixel if its similarity to the reference colour is within the range in the algorithm. + * For example, with this function, a user can change the color of all blue pixels by mixing them with red by 10%. + * # Arguments + * * `photon_image` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * * `new_color` - The `RGB` value of the new color (to be mixed with the matched pixels) + * * `fraction` - The amount of mixing the new colour with the matched pixels + * + * # Example + * + * ```no_run + * // 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%: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_color_convert; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(200, 120, 30); + * let new_color = Rgb::new(30, 120, 200); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_color_convert(&mut img, ref_color, new_color, 0.25); + * ``` + */ +export function selective_color_convert(photon_image: PhotonImage, ref_color: Rgb, new_color: Rgb, fraction: number): void; + +/** + * Selectively desaturate pixel colours which are similar to the reference colour provided. + * + * Similarity between two colours is calculated via the CIE76 formula. + * Only desaturates the hue of a pixel if its similarity to the reference colour is within the range in the algorithm. + * 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. + * # Arguments + * * `img` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * * `amt` - The amount of desaturate the colour by. + * + * # Example + * + * ```no_run + * // For example, to only desaturate the pixels that are similar to the RGB value RGB{20, 40, 60}: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_desaturate; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_desaturate(&mut img, ref_color, 0.1_f32); + * ``` + */ +export function selective_desaturate(img: PhotonImage, ref_color: Rgb, amt: number): void; + +/** + * Selectively changes a pixel to greyscale if it is *not* visually similar or close to the colour specified. + * Only changes the colour of a pixel if its RGB values are within a specified range. + * + * (Similarity between two colours is calculated via the CIE76 formula.) + * 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 + * kept in the photo. + * # Arguments + * * `img` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * + * # Example + * + * ```no_run + * // For example, to greyscale all pixels that are *not* visually similar to the RGB colour RGB{20, 40, 60}: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_greyscale; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_greyscale(img, ref_color); + * ``` + */ +export function selective_greyscale(photon_image: PhotonImage, ref_color: Rgb): void; + +/** + * Selective hue rotation. + * + * Only rotate the hue of a pixel if its RGB values are within a specified range. + * This function only rotates a pixel's hue to another if it is visually similar to the colour specified. + * 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. + * # Arguments + * * `img` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * * `degrees` - The amount of degrees to hue rotate by. + * + * # Example + * + * ```no_run + * // For example, to only rotate the pixels that are of RGB value RGB{20, 40, 60}: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_hue_rotate; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_hue_rotate(&mut img, ref_color, 180_f32); + * ``` + */ +export function selective_hue_rotate(photon_image: PhotonImage, ref_color: Rgb, degrees: number): void; + +/** + * Selectively lighten an image. + * + * Only lighten the hue of a pixel if its colour matches or is similar to the RGB colour specified. + * 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. + * # Arguments + * * `img` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * * `amt` - The level from 0 to 1 to lighten the hue by. Increasing by 10% would have an `amt` of 0.1 + * + * # Example + * + * ```no_run + * // For example, to only lighten the pixels that are of or similar to RGB value RGB{20, 40, 60}: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_lighten; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_lighten(&mut img, ref_color, 0.2_f32); + * ``` + */ +export function selective_lighten(img: PhotonImage, ref_color: Rgb, amt: number): void; + +/** + * Selectively saturate pixel colours which are similar to the reference colour provided. + * + * Similarity between two colours is calculated via the CIE76 formula. + * Only saturates the hue of a pixel if its similarity to the reference colour is within the range in the algorithm. + * 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. + * # Arguments + * * `img` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * * `amt` - The amount of saturate the colour by. + * + * # Example + * + * ```no_run + * // For example, to only increase the saturation of pixels that are similar to the RGB value RGB{20, 40, 60}: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_saturate; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_saturate(&mut img, ref_color, 0.1_f32); + * ``` + */ +export function selective_saturate(img: PhotonImage, ref_color: Rgb, amt: number): void; + +/** + * Convert an image to sepia. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * # Example + * + * ```no_run + * // For example, to sepia an image of type `PhotonImage`: + * use photon_rs::monochrome::sepia; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * sepia(&mut img); + * ``` + */ +export function sepia(img: PhotonImage): void; + +/** + * Sharpen an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to sharpen an image: + * use photon_rs::conv::sharpen; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * sharpen(&mut img); + * ``` + * Adds a constant to a select R, G, or B channel's value. + */ +export function sharpen(photon_image: PhotonImage): void; + +/** + * Shear the image along the X axis. + * A sheared PhotonImage is returned. + * + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `shear` - Amount to shear. + * + * # Example + * + * ```no_run + * // For example, to shear an image by 0.5: + * use photon_rs::native::open_image; + * use photon_rs::transform::shearx; + * + * let img = open_image("img.jpg").expect("File should open"); + * let sheared_img = shearx(&img, 0.5); + * ``` + */ +export function shearx(photon_img: PhotonImage, shear: number): PhotonImage; + +/** + * Shear the image along the Y axis. + * A sheared PhotonImage is returned. + * + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `shear` - Amount to shear. + * + * # Example + * + * ```no_run + * // For example, to shear an image by 0.5: + * use photon_rs::native::open_image; + * use photon_rs::transform::sheary; + * + * let img = open_image("img.jpg").expect("File should open"); + * let sheared_img = sheary(&img, 0.5); + * ``` + */ +export function sheary(photon_img: PhotonImage, shear: number): PhotonImage; + +/** + * Convert an image to grayscale by setting a pixel's 3 RGB values to a chosen channel's value. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `channel` - A usize representing the channel from 0 to 2. O represents the Red channel, 1 the Green channel, and 2 the Blue channel. + * + * # Example + * To grayscale using only values from the Red channel: + * ```no_run + * use photon_rs::monochrome::single_channel_grayscale; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * single_channel_grayscale(&mut img, 0_usize); + * ``` + */ +export function single_channel_grayscale(photon_image: PhotonImage, channel: number): void; + +/** + * Apply a global Sobel filter to an image + * + * Each pixel is calculated as the magnitude of the horizontal and vertical components of the Sobel filter, + * ie if X is the horizontal sobel and Y is the vertical, for each pixel, we calculate sqrt(X^2 + Y^2) + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a global Sobel filter: + * use photon_rs::conv::sobel_global; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * sobel_global(&mut img); + * ``` + */ +export function sobel_global(photon_image: PhotonImage): void; + +/** + * Apply a horizontal Sobel filter to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a horizontal Sobel filter: + * use photon_rs::conv::sobel_horizontal; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * sobel_horizontal(&mut img); + * ``` + */ +export function sobel_horizontal(photon_image: PhotonImage): void; + +/** + * Apply a vertical Sobel filter to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a vertical Sobel filter: + * use photon_rs::conv::sobel_vertical; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * sobel_vertical(&mut img); + * ``` + */ +export function sobel_vertical(photon_image: PhotonImage): void; + +/** + * Applies a solarizing effect to an image. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to colorize an image of type `PhotonImage`: + * use photon_rs::effects::solarize; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * solarize(&mut img); + * ``` + */ +export function solarize(photon_image: PhotonImage): void; + +/** + * Applies a solarizing effect to an image and returns the resulting PhotonImage. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to solarize "retimg" an image of type `PhotonImage`: + * use photon_rs::effects::solarize_retimg; + * use photon_rs::native::open_image; + * use photon_rs::PhotonImage; + * + * let img = open_image("img.jpg").expect("File should open"); + * let result: PhotonImage = solarize_retimg(&img); + * ``` + */ +export function solarize_retimg(photon_image: PhotonImage): PhotonImage; + +/** + * Swap two channels. + * + * # Arguments + * * `img` - A PhotonImage. + * * `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. + * * `channel2` - An index from 0 to 2, representing the Red, Green or Blue channels respectively. Same as above. + * + * # Example + * + * ```no_run + * // For example, to swap the values of the Red channel with the values of the Blue channel: + * use photon_rs::channels::swap_channels; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * swap_channels(&mut img, 0_usize, 2_usize); + * ``` + */ +export function swap_channels(img: PhotonImage, channel1: number, channel2: number): void; + +/** + * Threshold an image using a standard thresholding algorithm. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `threshold` - The amount the image should be thresholded by from 0 to 255. + * # Example + * + * ```no_run + * // For example, to threshold an image of type `PhotonImage`: + * use photon_rs::monochrome::threshold; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * threshold(&mut img, 30_u32); + * ``` + */ +export function threshold(img: PhotonImage, threshold: number): void; + +/** + * Tint an image by adding an offset to averaged RGB channel values. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `r_offset` - The amount the R channel should be incremented by. + * * `g_offset` - The amount the G channel should be incremented by. + * * `b_offset` - The amount the B channel should be incremented by. + * # Example + * + * ```no_run + * // For example, to tint an image of type `PhotonImage`: + * use photon_rs::effects::tint; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * tint(&mut img, 10_u32, 20_u32, 15_u32); + * ``` + */ +export function tint(photon_image: PhotonImage, r_offset: number, g_offset: number, b_offset: number): void; + +/** + * Convert a PhotonImage to JS-compatible ImageData. + */ +export function to_image_data(photon_image: PhotonImage): ImageData; + +/** + * Convert ImageData to a raw pixel vec of u8s. + */ +export function to_raw_pixels(imgdata: ImageData): Uint8Array; + +/** + * Vertical strips. Divide an image into a series of equal-width strips, for an artistic effect. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `num_strips` - The numbder of strips + * # Example + * + * ```no_run + * // For example, to draw vertical strips on a `PhotonImage`: + * use photon_rs::effects::vertical_strips; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * vertical_strips(&mut img, 8u8); + * ``` + */ +export function vertical_strips(photon_image: PhotonImage, num_strips: number): void; + +/** + * Add a watermark to an image. + * + * # Arguments + * * `img` - A DynamicImage that contains a view into the image. + * * `watermark` - The watermark to be placed onto the `img` image. + * * `x` - The x coordinate where the watermark's top corner should be positioned. + * * `y` - The y coordinate where the watermark's top corner should be positioned. + * # Example + * + * ```no_run + * // For example, to add a watermark to an image at x: 30, y: 40: + * use photon_rs::multiple::watermark; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let water_mark = open_image("watermark.jpg").expect("File should open"); + * watermark(&mut img, &water_mark, 30_i64, 40_i64); + * ``` + */ +export function watermark(img: PhotonImage, watermark: PhotonImage, x: bigint, y: bigint): void; diff --git a/packages/coding-agent/src/vendor/photon/index.js b/packages/coding-agent/src/vendor/photon/index.js new file mode 100644 index 000000000..5516c4f58 --- /dev/null +++ b/packages/coding-agent/src/vendor/photon/index.js @@ -0,0 +1,4459 @@ +/* @ts-self-types="./photon_rs.d.ts" */ + +/** + * Provides the image's height, width, and contains the image's raw pixels. + * For use when communicating between JS and WASM, and also natively. + */ +export class PhotonImage { + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(PhotonImage.prototype); + obj.__wbg_ptr = ptr; + PhotonImageFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + PhotonImageFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_photonimage_free(ptr, 0); + } + /** + * Convert the PhotonImage to base64. + * @returns {string} + */ + get_base64() { + let deferred1_0; + let deferred1_1; + try { + const ret = wasm.photonimage_get_base64(this.__wbg_ptr); + deferred1_0 = ret[0]; + deferred1_1 = ret[1]; + return getStringFromWasm0(ret[0], ret[1]); + } finally { + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Convert the PhotonImage to raw bytes. Returns PNG. + * @returns {Uint8Array} + */ + get_bytes() { + const ret = wasm.photonimage_get_bytes(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * Convert the PhotonImage to raw bytes. Returns a JPEG. + * @param {number} quality + * @returns {Uint8Array} + */ + get_bytes_jpeg(quality) { + const ret = wasm.photonimage_get_bytes_jpeg(this.__wbg_ptr, quality); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * Convert the PhotonImage to raw bytes. Returns a WEBP. + * @returns {Uint8Array} + */ + get_bytes_webp() { + const ret = wasm.photonimage_get_bytes_webp(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * Calculates estimated filesize and returns number of bytes + * @returns {bigint} + */ + get_estimated_filesize() { + const ret = wasm.photonimage_get_estimated_filesize(this.__wbg_ptr); + return BigInt.asUintN(64, ret); + } + /** + * Get the height of the PhotonImage. + * @returns {number} + */ + get_height() { + const ret = wasm.photonimage_get_height(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Convert the PhotonImage's raw pixels to JS-compatible ImageData. + * @returns {ImageData} + */ + get_image_data() { + const ret = wasm.photonimage_get_image_data(this.__wbg_ptr); + return ret; + } + /** + * Get the PhotonImage's pixels as a Vec of u8s. + * @returns {Uint8Array} + */ + get_raw_pixels() { + const ret = wasm.photonimage_get_raw_pixels(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * Get the width of the PhotonImage. + * @returns {number} + */ + get_width() { + const ret = wasm.photonimage_get_width(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Create a new PhotonImage from a Vec of u8s, which represent raw pixels. + * @param {Uint8Array} raw_pixels + * @param {number} width + * @param {number} height + */ + constructor(raw_pixels, width, height) { + const ptr0 = passArray8ToWasm0(raw_pixels, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.photonimage_new(ptr0, len0, width, height); + this.__wbg_ptr = ret >>> 0; + PhotonImageFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Create a new PhotonImage from a base64 string. + * @param {string} base64 + * @returns {PhotonImage} + */ + static new_from_base64(base64) { + const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.base64_to_image(ptr0, len0); + return PhotonImage.__wrap(ret); + } + /** + * Create a new PhotonImage from a Blob/File. + * @param {Blob} blob + * @returns {PhotonImage} + */ + static new_from_blob(blob) { + const ret = wasm.photonimage_new_from_blob(blob); + return PhotonImage.__wrap(ret); + } + /** + * Create a new PhotonImage from a byteslice. + * @param {Uint8Array} vec + * @returns {PhotonImage} + */ + static new_from_byteslice(vec) { + const ptr0 = passArray8ToWasm0(vec, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.photonimage_new_from_byteslice(ptr0, len0); + return PhotonImage.__wrap(ret); + } + /** + * Create a new PhotonImage from a HTMLImageElement + * @param {HTMLImageElement} image + * @returns {PhotonImage} + */ + static new_from_image(image) { + const ret = wasm.photonimage_new_from_image(image); + return PhotonImage.__wrap(ret); + } + /** + * Convert ImageData to raw pixels, and update the PhotonImage's raw pixels to this. + * @param {ImageData} img_data + */ + set_imgdata(img_data) { + wasm.photonimage_set_imgdata(this.__wbg_ptr, img_data); + } +} +if (Symbol.dispose) PhotonImage.prototype[Symbol.dispose] = PhotonImage.prototype.free; + +/** + * RGB color type. + */ +export class Rgb { + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + RgbFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_rgb_free(ptr, 0); + } + /** + * Get the Blue value. + * @returns {number} + */ + get_blue() { + const ret = wasm.rgb_get_blue(this.__wbg_ptr); + return ret; + } + /** + * Get the Green value. + * @returns {number} + */ + get_green() { + const ret = wasm.rgb_get_green(this.__wbg_ptr); + return ret; + } + /** + * Get the Red value. + * @returns {number} + */ + get_red() { + const ret = wasm.rgb_get_red(this.__wbg_ptr); + return ret; + } + /** + * Create a new RGB struct. + * @param {number} r + * @param {number} g + * @param {number} b + */ + constructor(r, g, b) { + const ret = wasm.rgb_new(r, g, b); + this.__wbg_ptr = ret >>> 0; + RgbFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Set the Blue value. + * @param {number} b + */ + set_blue(b) { + wasm.rgb_set_blue(this.__wbg_ptr, b); + } + /** + * Get the Green value. + * @param {number} g + */ + set_green(g) { + wasm.rgb_set_green(this.__wbg_ptr, g); + } + /** + * Set the Red value. + * @param {number} r + */ + set_red(r) { + wasm.rgb_set_red(this.__wbg_ptr, r); + } +} +if (Symbol.dispose) Rgb.prototype[Symbol.dispose] = Rgb.prototype.free; + +/** + * RGBA color type. + */ +export class Rgba { + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + RgbaFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_rgba_free(ptr, 0); + } + /** + * Get the alpha value for this color. + * @returns {number} + */ + get_alpha() { + const ret = wasm.rgba_get_alpha(this.__wbg_ptr); + return ret; + } + /** + * Get the Blue value. + * @returns {number} + */ + get_blue() { + const ret = wasm.rgb_get_blue(this.__wbg_ptr); + return ret; + } + /** + * Get the Green value. + * @returns {number} + */ + get_green() { + const ret = wasm.rgb_get_green(this.__wbg_ptr); + return ret; + } + /** + * Get the Red value. + * @returns {number} + */ + get_red() { + const ret = wasm.rgb_get_red(this.__wbg_ptr); + return ret; + } + /** + * Create a new RGBA struct. + * @param {number} r + * @param {number} g + * @param {number} b + * @param {number} a + */ + constructor(r, g, b, a) { + const ret = wasm.rgba_new(r, g, b, a); + this.__wbg_ptr = ret >>> 0; + RgbaFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Set the alpha value. + * @param {number} a + */ + set_alpha(a) { + wasm.rgba_set_alpha(this.__wbg_ptr, a); + } + /** + * Set the Blue value. + * @param {number} b + */ + set_blue(b) { + wasm.rgb_set_blue(this.__wbg_ptr, b); + } + /** + * Get the Green value. + * @param {number} g + */ + set_green(g) { + wasm.rgb_set_green(this.__wbg_ptr, g); + } + /** + * Set the Red value. + * @param {number} r + */ + set_red(r) { + wasm.rgb_set_red(this.__wbg_ptr, r); + } +} +if (Symbol.dispose) Rgba.prototype[Symbol.dispose] = Rgba.prototype.free; + +/** + * @enum {1 | 2 | 3 | 4 | 5} + */ +export const SamplingFilter = Object.freeze({ + Nearest: 1, "1": "Nearest", + Triangle: 2, "2": "Triangle", + CatmullRom: 3, "3": "CatmullRom", + Gaussian: 4, "4": "Gaussian", + Lanczos3: 5, "5": "Lanczos3", +}); + +/** + * Add randomized noise to an image. + * This function adds a Gaussian Noise Sample to each pixel through incrementing each channel by a randomized offset. + * This randomized offset is generated by creating a randomized thread pool. + * **[WASM SUPPORT IS AVAILABLE]**: Randomized thread pools cannot be created with WASM, but + * a workaround using js_sys::Math::random works now. + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example: + * use photon_rs::native::open_image; + * use photon_rs::noise::add_noise_rand; + * use photon_rs::PhotonImage; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * add_noise_rand(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function add_noise_rand(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.add_noise_rand(photon_image.__wbg_ptr); +} + +/** + * Adjust the brightness of an image by a factor. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `brightness` - A u8 to add or subtract to the brightness. To increase + * the brightness, pass a positive number (up to 255). To decrease the brightness, + * pass a negative number instead. + * # Example + * + * ```no_run + * use photon_rs::effects::adjust_brightness; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * adjust_brightness(&mut img, 10_i16); + * ``` + * @param {PhotonImage} photon_image + * @param {number} brightness + */ +export function adjust_brightness(photon_image, brightness) { + _assertClass(photon_image, PhotonImage); + wasm.adjust_brightness(photon_image.__wbg_ptr, brightness); +} + +/** + * Adjust the contrast of an image by a factor. + * + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * * `contrast` - An f32 factor used to adjust contrast. Between [-255.0, 255.0]. The algorithm will + * clamp results if passed factor is out of range. + * # Example + * + * ```no_run + * use photon_rs::effects::adjust_contrast; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * adjust_contrast(&mut img, 30_f32); + * ``` + * @param {PhotonImage} photon_image + * @param {number} contrast + */ +export function adjust_contrast(photon_image, contrast) { + _assertClass(photon_image, PhotonImage); + wasm.adjust_contrast(photon_image.__wbg_ptr, contrast); +} + +/** + * Increment or decrement every pixel's Blue channel by a constant. + * + * # Arguments + * * `img` - A PhotonImage. + * * `amt` - The amount to increment or decrement the channel's value by for that pixel. + * + * # Example + * + * ```no_run + * // For example, to increase the Blue channel for all pixels by 10: + * use photon_rs::channels::alter_blue_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_blue_channel(&mut img, 10_i16); + * ``` + * @param {PhotonImage} img + * @param {number} amt + */ +export function alter_blue_channel(img, amt) { + _assertClass(img, PhotonImage); + wasm.alter_blue_channel(img.__wbg_ptr, amt); +} + +/** + * Alter a select channel by incrementing or decrementing its value by a constant. + * + * # Arguments + * * `img` - A PhotonImage. + * * `channel` - The channel you wish to alter, it should be either 0, 1 or 2, + * representing R, G, or B respectively. (O=Red, 1=Green, 2=Blue) + * * `amount` - The amount to increment/decrement the channel's value by for that pixel. + * A positive value will increment/decrement the channel's value, a negative value will decrement the channel's value. + * + * ## Example + * + * ```no_run + * // For example, to increase the Red channel for all pixels by 10: + * use photon_rs::channels::alter_channel; + * use photon_rs::native::{open_image}; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_channel(&mut img, 0_usize, 10_i16); + * ``` + * + * Adds a constant to a select R, G, or B channel's value. + * + * ### Decrease a channel's value + * // For example, to decrease the Green channel for all pixels by 20: + * ```no_run + * use photon_rs::channels::alter_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_channel(&mut img, 1_usize, -20_i16); + * ``` + * **Note**: Note the use of a minus symbol when decreasing the channel. + * @param {PhotonImage} img + * @param {number} channel + * @param {number} amt + */ +export function alter_channel(img, channel, amt) { + _assertClass(img, PhotonImage); + wasm.alter_channel(img.__wbg_ptr, channel, amt); +} + +/** + * Increment all 3 channels' values by adding an amt to each channel per pixel. + * + * # Arguments + * * `img` - A PhotonImage. + * * `r_amt` - The amount to increment/decrement the Red channel by. + * * `g_amt` - The amount to increment/decrement the Green channel by. + * * `b_amt` - The amount to increment/decrement the Blue channel by. + * + * # Example + * + * ```no_run + * // For example, to increase the values of the Red channel by 10, the Green channel by 20, + * // and the Blue channel by 50: + * use photon_rs::channels::alter_channels; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_channels(&mut img, 10_i16, 20_i16, 50_i16); + * ``` + * @param {PhotonImage} img + * @param {number} r_amt + * @param {number} g_amt + * @param {number} b_amt + */ +export function alter_channels(img, r_amt, g_amt, b_amt) { + _assertClass(img, PhotonImage); + wasm.alter_channels(img.__wbg_ptr, r_amt, g_amt, b_amt); +} + +/** + * Increment or decrement every pixel's Green channel by a constant. + * + * # Arguments + * * `img` - A PhotonImage. + * * `amt` - The amount to increment/decrement the channel's value by for that pixel. + * + * # Example + * + * ```no_run + * // For example, to increase the Green channel for all pixels by 20: + * use photon_rs::channels::alter_green_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_green_channel(&mut img, 20_i16); + * ``` + * @param {PhotonImage} img + * @param {number} amt + */ +export function alter_green_channel(img, amt) { + _assertClass(img, PhotonImage); + wasm.alter_green_channel(img.__wbg_ptr, amt); +} + +/** + * Increment or decrement every pixel's Red channel by a constant. + * + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `amt` - The amount to increment or decrement the channel's value by for that pixel. + * + * # Example + * + * ```no_run + * // For example, to increase the Red channel for all pixels by 10: + * use photon_rs::channels::alter_red_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_red_channel(&mut img, 10_i16); + * ``` + * @param {PhotonImage} photon_image + * @param {number} amt + */ +export function alter_red_channel(photon_image, amt) { + _assertClass(photon_image, PhotonImage); + wasm.alter_red_channel(photon_image.__wbg_ptr, amt); +} + +/** + * Increment/decrement two channels' values simultaneously by adding an amt to each channel per pixel. + * + * # Arguments + * * `img` - A PhotonImage. + * * `channel1` - A usize from 0 to 2 that represents either the R, G or B channels. + * * `amt1` - The amount to increment/decrement the channel's value by for that pixel. + * * `channel2` -A usize from 0 to 2 that represents either the R, G or B channels. + * * `amt2` - The amount to increment/decrement the channel's value by for that pixel. + * + * # Example + * + * ```no_run + * // For example, to increase the values of the Red and Blue channels per pixel: + * use photon_rs::channels::alter_two_channels; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * alter_two_channels(&mut img, 0_usize, 10_i16, 2_usize, 20_i16); + * ``` + * @param {PhotonImage} img + * @param {number} channel1 + * @param {number} amt1 + * @param {number} channel2 + * @param {number} amt2 + */ +export function alter_two_channels(img, channel1, amt1, channel2, amt2) { + _assertClass(img, PhotonImage); + wasm.alter_two_channels(img.__wbg_ptr, channel1, amt1, channel2, amt2); +} + +/** + * Apply a gradient to an image. + * @param {PhotonImage} image + */ +export function apply_gradient(image) { + _assertClass(image, PhotonImage); + wasm.apply_gradient(image.__wbg_ptr); +} + +/** + * Convert an image to grayscale by setting a pixel's 3 RGB values to the Blue channel's value. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * + * # Example + * + * ```no_run + * use photon_rs::monochrome::b_grayscale; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * b_grayscale(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function b_grayscale(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.b_grayscale(photon_image.__wbg_ptr); +} + +/** + * Convert a base64 string to a PhotonImage. + * @param {string} base64 + * @returns {PhotonImage} + */ +export function base64_to_image(base64) { + const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.base64_to_image(ptr0, len0); + return PhotonImage.__wrap(ret); +} + +/** + * Convert a base64 string to a Vec of u8s. + * @param {string} base64 + * @returns {Uint8Array} + */ +export function base64_to_vec(base64) { + const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.base64_to_vec(ptr0, len0); + var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v2; +} + +/** + * Blend two images together. + * + * The `blend_mode` (3rd param) determines which blending mode to use; change this for varying effects. + * The blend modes available include: `overlay`, `over`, `atop`, `xor`, `plus`, `multiply`, `burn`, + * `difference`, `soft_light`, `screen`, `hard_light`, `dodge`, `exclusion`, `lighten`, `darken` (more to come) + * NOTE: The first image must be smaller than the second image passed as params. + * If the first image were larger than the second, then there would be overflowing pixels which would have no corresponding pixels + * in the second image. + * # Arguments + * * `img` - A DynamicImage that contains a view into the image. + * * `img2` - The 2nd DynamicImage to be blended with the first. + * * `blend_mode` - The blending mode to use. See above for complete list of blend modes available. + * # Example + * + * ```no_run + * // For example, to blend two images with the `multiply` blend mode: + * use photon_rs::multiple::blend; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let img2 = open_image("img2.jpg").expect("File should open"); + * blend(&mut img, &img2, "multiply"); + * ``` + * @param {PhotonImage} photon_image + * @param {PhotonImage} photon_image2 + * @param {string} blend_mode + */ +export function blend(photon_image, photon_image2, blend_mode) { + _assertClass(photon_image, PhotonImage); + _assertClass(photon_image2, PhotonImage); + const ptr0 = passStringToWasm0(blend_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.blend(photon_image.__wbg_ptr, photon_image2.__wbg_ptr, ptr0, len0); +} + +/** + * Apply a box blur effect. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a box blur effect: + * use photon_rs::conv::box_blur; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * box_blur(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function box_blur(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.box_blur(photon_image.__wbg_ptr); +} + +/** + * Increased contrast filter effect. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::cali; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * cali(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function cali(img) { + _assertClass(img, PhotonImage); + wasm.cali(img.__wbg_ptr); +} + +/** + * Horizontal strips. Divide an image into a series of equal-width strips, for an artistic effect. Sepcify a color as well. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `num_strips` - The numbder of strips + * * `color` - Color of strips. + * # Example + * + * ```no_run + * // For example, to draw blue horizontal strips on a `PhotonImage`: + * use photon_rs::effects::color_horizontal_strips; + * use photon_rs::native::open_image; + * use photon_rs::Rgb; + * + * let color = Rgb::new(255u8, 0u8, 0u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * color_horizontal_strips(&mut img, 8u8, color); + * ``` + * @param {PhotonImage} photon_image + * @param {number} num_strips + * @param {Rgb} color + */ +export function color_horizontal_strips(photon_image, num_strips, color) { + _assertClass(photon_image, PhotonImage); + _assertClass(color, Rgb); + var ptr0 = color.__destroy_into_raw(); + wasm.color_horizontal_strips(photon_image.__wbg_ptr, num_strips, ptr0); +} + +/** + * Vertical strips. Divide an image into a series of equal-width strips, for an artistic effect. Sepcify a color as well. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `num_strips` - The numbder of strips + * * `color` - Color of strips. + * # Example + * + * ```no_run + * // For example, to draw red vertical strips on a `PhotonImage`: + * use photon_rs::effects::color_vertical_strips; + * use photon_rs::native::open_image; + * use photon_rs::Rgb; + * + * let color = Rgb::new(255u8, 0u8, 0u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * color_vertical_strips(&mut img, 8u8, color); + * ``` + * @param {PhotonImage} photon_image + * @param {number} num_strips + * @param {Rgb} color + */ +export function color_vertical_strips(photon_image, num_strips, color) { + _assertClass(photon_image, PhotonImage); + _assertClass(color, Rgb); + var ptr0 = color.__destroy_into_raw(); + wasm.color_vertical_strips(photon_image.__wbg_ptr, num_strips, ptr0); +} + +/** + * Colorizes the green channels of the image. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to colorize an image of type `PhotonImage`: + * use photon_rs::effects::colorize; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * colorize(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function colorize(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.colorize(photon_image.__wbg_ptr); +} + +/** + * @param {number} width + * @param {number} height + * @returns {PhotonImage} + */ +export function create_gradient(width, height) { + const ret = wasm.create_gradient(width, height); + return PhotonImage.__wrap(ret); +} + +/** + * Crop an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to crop an image at (0, 0) to (500, 800) + * use photon_rs::native::{open_image}; + * use photon_rs::transform::crop; + * use photon_rs::PhotonImage; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let cropped_img: PhotonImage = crop(&img, 0_u32, 0_u32, 500_u32, 800_u32); + * // Write the contents of this image in JPG format. + * ``` + * @param {PhotonImage} photon_image + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @returns {PhotonImage} + */ +export function crop(photon_image, x1, y1, x2, y2) { + _assertClass(photon_image, PhotonImage); + const ret = wasm.crop(photon_image.__wbg_ptr, x1, y1, x2, y2); + return PhotonImage.__wrap(ret); +} + +/** + * @param {HTMLCanvasElement} source_canvas + * @param {number} width + * @param {number} height + * @param {number} left + * @param {number} top + * @returns {HTMLCanvasElement} + */ +export function crop_img_browser(source_canvas, width, height, left, top) { + const ret = wasm.crop_img_browser(source_canvas, width, height, left, top); + return ret; +} + +/** + * Darken the image by a specified amount in the HSL colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to darken the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Darkening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to darken an image by 10% in the HSL colour space: + * use photon_rs::colour_spaces::darken_hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * darken_hsl(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function darken_hsl(img, level) { + _assertClass(img, PhotonImage); + wasm.darken_hsl(img.__wbg_ptr, level); +} + +/** + * Darken the image by a specified amount in the HSLuv colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to darken the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Darkening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to darken an image by 10% in the HSLuv colour space: + * use photon_rs::colour_spaces::darken_hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * darken_hsluv(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function darken_hsluv(img, level) { + _assertClass(img, PhotonImage); + wasm.darken_hsluv(img.__wbg_ptr, level); +} + +/** + * Darken the image's colours by a specified amount in the HSV colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to darken the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Darkening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to darken an image by 10% in the HSV colour space: + * use photon_rs::colour_spaces::darken_hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * darken_hsv(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function darken_hsv(img, level) { + _assertClass(img, PhotonImage); + wasm.darken_hsv(img.__wbg_ptr, level); +} + +/** + * Darken the image by a specified amount in the LCh colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to darken the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Darkening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to darken an image by 10% in the LCh colour space: + * use photon_rs::colour_spaces::darken_lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * darken_lch(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function darken_lch(img, level) { + _assertClass(img, PhotonImage); + wasm.darken_lch(img.__wbg_ptr, level); +} + +/** + * Decrease the brightness of an image by a constant. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `brightness` - A u8 to subtract from the brightness. It should be a positive number, + * and this value will then be subtracted from the brightness. + * # Example + * + * ```no_run + * use photon_rs::effects::dec_brightness; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * dec_brightness(&mut img, 10_u8); + * ``` + * @param {PhotonImage} photon_image + * @param {number} brightness + */ +export function dec_brightness(photon_image, brightness) { + _assertClass(photon_image, PhotonImage); + wasm.dec_brightness(photon_image.__wbg_ptr, brightness); +} + +/** + * Uses a max. decomposition algorithm to convert an image to greyscale. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to decompose an image with max decomposition: + * use photon_rs::monochrome::decompose_max; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * decompose_max(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function decompose_max(img) { + _assertClass(img, PhotonImage); + wasm.decompose_max(img.__wbg_ptr); +} + +/** + * Uses a min. decomposition algorithm to convert an image to greyscale. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to decompose an image with min decomposition: + * use photon_rs::monochrome::decompose_min; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * decompose_min(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function decompose_min(img) { + _assertClass(img, PhotonImage); + wasm.decompose_min(img.__wbg_ptr); +} + +/** + * Desaturate an image by getting the min/max of each pixel's RGB values. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * # Example + * + * ```no_run + * // For example, to desaturate an image: + * use photon_rs::monochrome::desaturate; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * desaturate(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function desaturate(img) { + _assertClass(img, PhotonImage); + wasm.desaturate(img.__wbg_ptr); +} + +/** + * Desaturate the image by a specified amount in the HSL colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Desaturating by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to desaturate an image by 10% in the LCh colour space: + * use photon_rs::colour_spaces::desaturate_hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * desaturate_hsl(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function desaturate_hsl(img, level) { + _assertClass(img, PhotonImage); + wasm.desaturate_hsl(img.__wbg_ptr, level); +} + +/** + * Desaturate the image by a specified amount in the HSLuv colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Desaturating by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to desaturate an image by 10% in the HSLuv colour space: + * use photon_rs::colour_spaces::desaturate_hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * desaturate_hsluv(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function desaturate_hsluv(img, level) { + _assertClass(img, PhotonImage); + wasm.desaturate_hsluv(img.__wbg_ptr, level); +} + +/** + * Desaturate the image by a specified amount in the HSV colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Desaturating by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to desaturate an image by 10% in the HSV colour space: + * use photon_rs::colour_spaces::desaturate_hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * desaturate_hsv(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function desaturate_hsv(img, level) { + _assertClass(img, PhotonImage); + wasm.desaturate_hsv(img.__wbg_ptr, level); +} + +/** + * Desaturate the image by a specified amount in the LCh colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Desaturating by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to desaturate an image by 10% in the LCh colour space: + * use photon_rs::colour_spaces::desaturate_lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * desaturate_lch(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function desaturate_lch(img, level) { + _assertClass(img, PhotonImage); + wasm.desaturate_lch(img.__wbg_ptr, level); +} + +/** + * Detect lines at a 135 degree angle in an image, and highlight these only. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to display the lines at a 135 degree angle in an image: + * use photon_rs::conv::detect_135_deg_lines; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * detect_135_deg_lines(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function detect_135_deg_lines(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.detect_135_deg_lines(photon_image.__wbg_ptr); +} + +/** + * Detect lines at a forty five degree angle in an image, and highlight these only. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to display the lines at a forty five degree angle in an image: + * use photon_rs::conv::detect_45_deg_lines; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * detect_45_deg_lines(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function detect_45_deg_lines(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.detect_45_deg_lines(photon_image.__wbg_ptr); +} + +/** + * Detect horizontal lines in an image, and highlight these only. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to display the horizontal lines in an image: + * use photon_rs::conv::detect_horizontal_lines; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * detect_horizontal_lines(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function detect_horizontal_lines(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.detect_horizontal_lines(photon_image.__wbg_ptr); +} + +/** + * Detect vertical lines in an image, and highlight these only. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to display the vertical lines in an image: + * use photon_rs::conv::detect_vertical_lines; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * detect_vertical_lines(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function detect_vertical_lines(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.detect_vertical_lines(photon_image.__wbg_ptr); +} + +/** + * Applies Floyd-Steinberg dithering to an image. + * Only RGB channels are processed, alpha remains unchanged. + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * * `depth` - bits per channel. Clamped between 1 and 8. + * # Example + * + * ```no_run + * // For example, to turn an image of type `PhotonImage` into a dithered image: + * use photon_rs::effects::dither; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let depth = 1; + * dither(&mut img, depth); + * ``` + * @param {PhotonImage} photon_image + * @param {number} depth + */ +export function dither(photon_image, depth) { + _assertClass(photon_image, PhotonImage); + wasm.dither(photon_image.__wbg_ptr, depth); +} + +/** + * Greyscale effect with increased contrast. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::dramatic; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * dramatic(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function dramatic(img) { + _assertClass(img, PhotonImage); + wasm.dramatic(img.__wbg_ptr); +} + +/** + * Add text to an image. + * The only font available as of now is Roboto. + * Note: A graphic design/text-drawing library is currently being developed, so stay tuned. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `text` - Text string to be drawn to the image. + * * `x` - x-coordinate of where first letter's 1st pixel should be drawn. + * * `y` - y-coordinate of where first letter's 1st pixel should be drawn. + * * `font_size` - Font size in pixels of the text to be drawn. + * + * # Example + * + * ```no_run + * // For example to draw the string "Welcome to Photon!" at 10, 10: + * use photon_rs::native::open_image; + * use photon_rs::text::draw_text; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * draw_text(&mut img, "Welcome to Photon!", 10_i32, 10_i32, 90_f32); + * ``` + * @param {PhotonImage} photon_img + * @param {string} text + * @param {number} x + * @param {number} y + * @param {number} font_size + */ +export function draw_text(photon_img, text, x, y, font_size) { + _assertClass(photon_img, PhotonImage); + const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.draw_text(photon_img.__wbg_ptr, ptr0, len0, x, y, font_size); +} + +/** + * Add bordered-text to an image. + * The only font available as of now is Roboto. + * Note: A graphic design/text-drawing library is currently being developed, so stay tuned. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `text` - Text string to be drawn to the image. + * * `x` - x-coordinate of where first letter's 1st pixel should be drawn. + * * `y` - y-coordinate of where first letter's 1st pixel should be drawn. + * * `font_size` - Font size in pixels of the text to be drawn. + * + * # Example + * + * ```no_run + * // For example to draw the string "Welcome to Photon!" at 10, 10: + * use photon_rs::native::open_image; + * use photon_rs::text::draw_text_with_border; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * draw_text_with_border(&mut img, "Welcome to Photon!", 10_i32, 10_i32, 90_f32); + * ``` + * @param {PhotonImage} photon_img + * @param {string} text + * @param {number} x + * @param {number} y + * @param {number} font_size + */ +export function draw_text_with_border(photon_img, text, x, y, font_size) { + _assertClass(photon_img, PhotonImage); + const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.draw_text_with_border(photon_img.__wbg_ptr, ptr0, len0, x, y, font_size); +} + +/** + * @param {PhotonImage} photon_image + * @param {Rgb} color_a + * @param {Rgb} color_b + */ +export function duotone(photon_image, color_a, color_b) { + _assertClass(photon_image, PhotonImage); + _assertClass(color_a, Rgb); + var ptr0 = color_a.__destroy_into_raw(); + _assertClass(color_b, Rgb); + var ptr1 = color_b.__destroy_into_raw(); + wasm.duotone(photon_image.__wbg_ptr, ptr0, ptr1); +} + +/** + * Duotone effect with purple tones. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::duotone_horizon; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * duotone_horizon(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function duotone_horizon(img) { + _assertClass(img, PhotonImage); + wasm.duotone_horizon(img.__wbg_ptr); +} + +/** + * Duotone effect with a lilac hue + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::duotone_lilac; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * duotone_lilac(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function duotone_lilac(img) { + _assertClass(img, PhotonImage); + wasm.duotone_lilac(img.__wbg_ptr); +} + +/** + * A duotone ochre tint effect + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::duotone_ochre; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * duotone_ochre(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function duotone_ochre(img) { + _assertClass(img, PhotonImage); + wasm.duotone_ochre(img.__wbg_ptr); +} + +/** + * A duotone filter with a user-specified color and a gray color + * + * # Arguments + * * `img` - A PhotonImage. + * * `rgb_color` - RGB color + * # Example + * + * ```no_run + * use photon_rs::filters::duotone_tint; + * use photon_rs::native::open_image; + * use photon_rs::Rgb; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgb_color = Rgb::new(12, 12, 10); + * duotone_tint(&mut img, rgb_color); + * ``` + * @param {PhotonImage} img + * @param {Rgb} rgb_color + */ +export function duotone_tint(img, rgb_color) { + _assertClass(img, PhotonImage); + _assertClass(rgb_color, Rgb); + var ptr0 = rgb_color.__destroy_into_raw(); + wasm.duotone_tint(img.__wbg_ptr, ptr0); +} + +/** + * Duotone effect with blue and purple tones. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::duotone_violette; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * duotone_violette(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function duotone_violette(img) { + _assertClass(img, PhotonImage); + wasm.duotone_violette(img.__wbg_ptr); +} + +/** + * Apply edge detection to an image, to create a dark version with its edges highlighted. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to increase the Red channel for all pixels by 10: + * use photon_rs::conv::edge_detection; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * edge_detection(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function edge_detection(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.edge_detection(photon_image.__wbg_ptr); +} + +/** + * Preset edge effect. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply this effect: + * use photon_rs::conv::edge_one; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * edge_one(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function edge_one(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.edge_one(photon_image.__wbg_ptr); +} + +/** + * Apply an emboss effect to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply an emboss effect: + * use photon_rs::conv::emboss; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * emboss(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function emboss(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.emboss(photon_image.__wbg_ptr); +} + +/** + * Apply a filter to an image. Over 20 filters are available. + * The filters are as follows: + * * **oceanic**: Add an aquamarine-tinted hue to an image. + * * **islands**: Aquamarine tint. + * * **marine**: Add a green/blue mixed hue to an image. + * * **seagreen**: Dark green hue, with tones of blue. + * * **flagblue**: Royal blue tint + * * **liquid**: Blue-inspired tint. + * * **diamante**: Custom filter with a blue/turquoise tint. + * * **radio**: Fallout-style radio effect. + * * **twenties**: Slight-blue tinted historical effect. + * * **rosetint**: Rose-tinted filter. + * * **mauve**: Purple-infused filter. + * * **bluechrome**: Blue monochrome effect. + * * **vintage**: Vintage filter with a red tint. + * * **perfume**: Increase the blue channel, with moderate increases in the Red and Green channels. + * * **serenity**: Custom filter with an increase in the Blue channel's values. + * # Arguments + * * `img` - A PhotonImage. + * * `filter_name` - The filter's name. Choose from the selection above, eg: "oceanic" + * # Example + * + * ```no_run + * // For example, to add a filter called "vintage" to an image: + * use photon_rs::filters::filter; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * filter(&mut img, "vintage"); + * ``` + * @param {PhotonImage} img + * @param {string} filter_name + */ +export function filter(img, filter_name) { + _assertClass(img, PhotonImage); + const ptr0 = passStringToWasm0(filter_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.filter(img.__wbg_ptr, ptr0, len0); +} + +/** + * Apply a red hue, with increased contrast and brightness. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::firenze; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * firenze(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function firenze(img) { + _assertClass(img, PhotonImage); + wasm.firenze(img.__wbg_ptr); +} + +/** + * Flip an image horizontally. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to flip an image horizontally: + * use photon_rs::native::open_image; + * use photon_rs::transform::fliph; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * fliph(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function fliph(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.fliph(photon_image.__wbg_ptr); +} + +/** + * Flip an image vertically. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to flip an image vertically: + * use photon_rs::native::open_image; + * use photon_rs::transform::flipv; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * flipv(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function flipv(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.flipv(photon_image.__wbg_ptr); +} + +/** + * Turn an image into an frosted glass see through + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to turn an image of type `PhotonImage` into frosted glass see through: + * use photon_rs::effects::frosted_glass; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * frosted_glass(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function frosted_glass(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.frosted_glass(photon_image.__wbg_ptr); +} + +/** + * Convert an image to grayscale by setting a pixel's 3 RGB values to the Green channel's value. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * + * # Example + * + * ```no_run + * use photon_rs::monochrome::g_grayscale; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * g_grayscale(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function g_grayscale(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.g_grayscale(photon_image.__wbg_ptr); +} + +/** + * Applies gamma correction to an image. + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * * `red` - Gamma value for red channel. + * * `green` - Gamma value for green channel. + * * `blue` - Gamma value for blue channel. + * # Example + * + * ```no_run + * // For example, to turn an image of type `PhotonImage` into a gamma corrected image: + * use photon_rs::colour_spaces::gamma_correction; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * gamma_correction(&mut img, 2.2, 2.2, 2.2); + * ``` + * @param {PhotonImage} photon_image + * @param {number} red + * @param {number} green + * @param {number} blue + */ +export function gamma_correction(photon_image, red, green, blue) { + _assertClass(photon_image, PhotonImage); + wasm.gamma_correction(photon_image.__wbg_ptr, red, green, blue); +} + +/** + * Gaussian blur in linear time. + * + * Reference: http://blog.ivank.net/fastest-gaussian-blur.html + * + * # Arguments + * * `photon_image` - A PhotonImage + * * `radius` - blur radius + * # Example + * + * ```no_run + * use photon_rs::conv::gaussian_blur; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * gaussian_blur(&mut img, 3_i32); + * ``` + * @param {PhotonImage} photon_image + * @param {number} radius + */ +export function gaussian_blur(photon_image, radius) { + _assertClass(photon_image, PhotonImage); + wasm.gaussian_blur(photon_image.__wbg_ptr, radius); +} + +/** + * Get the ImageData from a 2D canvas context + * @param {HTMLCanvasElement} canvas + * @param {CanvasRenderingContext2D} ctx + * @returns {ImageData} + */ +export function get_image_data(canvas, ctx) { + const ret = wasm.get_image_data(canvas, ctx); + return ret; +} + +/** + * Apply a vintage, golden hue to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::golden; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * golden(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function golden(img) { + _assertClass(img, PhotonImage); + wasm.golden(img.__wbg_ptr); +} + +/** + * Convert an image to grayscale using the conventional averaging algorithm. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * # Example + * + * ```no_run + * // For example, to convert an image of type `PhotonImage` to grayscale: + * use photon_rs::monochrome::grayscale; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * grayscale(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function grayscale(img) { + _assertClass(img, PhotonImage); + wasm.grayscale(img.__wbg_ptr); +} + +/** + * Convert an image to grayscale with a human corrected factor, to account for human vision. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * # Example + * + * ```no_run + * // For example, to convert an image of type `PhotonImage` to grayscale with a human corrected factor: + * use photon_rs::monochrome::grayscale_human_corrected; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * grayscale_human_corrected(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function grayscale_human_corrected(img) { + _assertClass(img, PhotonImage); + wasm.grayscale_human_corrected(img.__wbg_ptr); +} + +/** + * Employ only a limited number of gray shades in an image. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `num_shades` - The number of grayscale shades to be displayed in the image. + * + * # Example + * + * ```no_run + * // For example, to limit an image to four shades of gray only: + * use photon_rs::monochrome::grayscale_shades; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * grayscale_shades(&mut img, 4_u8); + * ``` + * @param {PhotonImage} photon_image + * @param {number} num_shades + */ +export function grayscale_shades(photon_image, num_shades) { + _assertClass(photon_image, PhotonImage); + wasm.grayscale_shades(photon_image.__wbg_ptr, num_shades); +} + +/** + * Halftoning effect. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example: + * use photon_rs::effects::halftone; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * halftone(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function halftone(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.halftone(photon_image.__wbg_ptr); +} + +/** + * Horizontal strips. Divide an image into a series of equal-height strips, for an artistic effect. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `num_strips` - The number of strips + * # Example + * + * ```no_run + * // For example, to draw horizontal strips on a `PhotonImage`: + * use photon_rs::effects::horizontal_strips; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * horizontal_strips(&mut img, 8u8); + * ``` + * @param {PhotonImage} photon_image + * @param {number} num_strips + */ +export function horizontal_strips(photon_image, num_strips) { + _assertClass(photon_image, PhotonImage); + wasm.horizontal_strips(photon_image.__wbg_ptr, num_strips); +} + +/** + * Image manipulation effects in the HSL colour space. + * + * Effects include: + * * **saturate** - Saturation increase. + * * **desaturate** - Desaturate the image. + * * **shift_hue** - Hue rotation by a specified number of degrees. + * * **darken** - Decrease the brightness. + * * **lighten** - Increase the brightness. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten` + * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by. + * # Example + * ```no_run + * // For example to increase the saturation by 10%: + * use photon_rs::colour_spaces::hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hsl(&mut img, "saturate", 0.1_f32); + * ``` + * @param {PhotonImage} photon_image + * @param {string} mode + * @param {number} amt + */ +export function hsl(photon_image, mode, amt) { + _assertClass(photon_image, PhotonImage); + const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.hsl(photon_image.__wbg_ptr, ptr0, len0, amt); +} + +/** + * Image manipulation effects in the HSLuv colour space + * + * Effects include: + * * **saturate** - Saturation increase. + * * **desaturate** - Desaturate the image. + * * **shift_hue** - Hue rotation by a specified number of degrees. + * * **darken** - Decrease the brightness. + * * **lighten** - Increase the brightness. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten` + * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by. + * # Example + * ```no_run + * // For example to increase the saturation by 10%: + * use photon_rs::colour_spaces::hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hsluv(&mut img, "saturate", 0.1_f32); + * ``` + * @param {PhotonImage} photon_image + * @param {string} mode + * @param {number} amt + */ +export function hsluv(photon_image, mode, amt) { + _assertClass(photon_image, PhotonImage); + const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.hsluv(photon_image.__wbg_ptr, ptr0, len0, amt); +} + +/** + * Image manipulation in the HSV colour space. + * + * Effects include: + * * **saturate** - Saturation increase. + * * **desaturate** - Desaturate the image. + * * **shift_hue** - Hue rotation by a specified number of degrees. + * * **darken** - Decrease the brightness. + * * **lighten** - Increase the brightness. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten` + * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by. + * + * # Example + * ```no_run + * // For example to increase the saturation by 10%: + * use photon_rs::colour_spaces::hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hsv(&mut img, "saturate", 0.1_f32); + * ``` + * @param {PhotonImage} photon_image + * @param {string} mode + * @param {number} amt + */ +export function hsv(photon_image, mode, amt) { + _assertClass(photon_image, PhotonImage); + const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.hsv(photon_image.__wbg_ptr, ptr0, len0, amt); +} + +/** + * Shift hue by a specified number of degrees in the HSL colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by. + * + * # Example + * ```no_run + * // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space: + * use photon_rs::colour_spaces::hue_rotate_hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hue_rotate_hsl(&mut img, 120_f32); + * ``` + * @param {PhotonImage} img + * @param {number} degrees + */ +export function hue_rotate_hsl(img, degrees) { + _assertClass(img, PhotonImage); + wasm.hue_rotate_hsl(img.__wbg_ptr, degrees); +} + +/** + * Shift hue by a specified number of degrees in the HSLuv colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by. + * + * # Example + * ```no_run + * // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space: + * use photon_rs::colour_spaces::hue_rotate_hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hue_rotate_hsluv(&mut img, 120_f32); + * ``` + * @param {PhotonImage} img + * @param {number} degrees + */ +export function hue_rotate_hsluv(img, degrees) { + _assertClass(img, PhotonImage); + wasm.hue_rotate_hsluv(img.__wbg_ptr, degrees); +} + +/** + * Shift hue by a specified number of degrees in the HSV colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by. + * + * # Example + * ```no_run + * // For example to hue rotate/shift the hue by 120 degrees in the HSV colour space: + * use photon_rs::colour_spaces::hue_rotate_hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hue_rotate_hsv(&mut img, 120_f32); + * ``` + * @param {PhotonImage} img + * @param {number} degrees + */ +export function hue_rotate_hsv(img, degrees) { + _assertClass(img, PhotonImage); + wasm.hue_rotate_hsv(img.__wbg_ptr, degrees); +} + +/** + * Shift hue by a specified number of degrees in the LCh colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by. + * + * # Example + * ```no_run + * // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space: + * use photon_rs::colour_spaces::hue_rotate_lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * hue_rotate_lch(&mut img, 120_f32); + * ``` + * @param {PhotonImage} img + * @param {number} degrees + */ +export function hue_rotate_lch(img, degrees) { + _assertClass(img, PhotonImage); + wasm.hue_rotate_lch(img.__wbg_ptr, degrees); +} + +/** + * Apply an identity kernel convolution to an image. + * + * # Arguments + * * `img` -A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply an identity kernel convolution: + * use photon_rs::conv::identity; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * identity(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function identity(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.identity(photon_image.__wbg_ptr); +} + +/** + * Increase the brightness of an image by a constant. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `brightness` - A u8 to add to the brightness. + * # Example + * + * ```no_run + * use photon_rs::effects::inc_brightness; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * inc_brightness(&mut img, 10_u8); + * ``` + * @param {PhotonImage} photon_image + * @param {number} brightness + */ +export function inc_brightness(photon_image, brightness) { + _assertClass(photon_image, PhotonImage); + wasm.inc_brightness(photon_image.__wbg_ptr, brightness); +} + +/** + * Invert RGB value of an image. + * + * # Arguments + * * `photon_image` - A DynamicImage that contains a view into the image. + * # Example + * + * ```no_run + * use photon_rs::channels::invert; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * invert(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function invert(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.invert(photon_image.__wbg_ptr); +} + +/** + * Apply a standard laplace convolution. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a laplace effect: + * use photon_rs::conv::laplace; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * laplace(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function laplace(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.laplace(photon_image.__wbg_ptr); +} + +/** + * Image manipulation effects in the LCh colour space + * + * Effects include: + * * **saturate** - Saturation increase. + * * **desaturate** - Desaturate the image. + * * **shift_hue** - Hue rotation by a specified number of degrees. + * * **darken** - Decrease the brightness. + * * **lighten** - Increase the brightness. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten` + * * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by. + * # Example + * ```no_run + * // For example to increase the saturation by 10%: + * use photon_rs::colour_spaces::lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * lch(&mut img, "saturate", 0.1_f32); + * ``` + * @param {PhotonImage} photon_image + * @param {string} mode + * @param {number} amt + */ +export function lch(photon_image, mode, amt) { + _assertClass(photon_image, PhotonImage); + const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.lch(photon_image.__wbg_ptr, ptr0, len0, amt); +} + +/** + * Lighten an image by a specified amount in the HSL colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Lightening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to lighten an image by 10% in the HSL colour space: + * use photon_rs::colour_spaces::lighten_hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * lighten_hsl(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function lighten_hsl(img, level) { + _assertClass(img, PhotonImage); + wasm.lighten_hsl(img.__wbg_ptr, level); +} + +/** + * Lighten an image by a specified amount in the HSLuv colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Lightening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to lighten an image by 10% in the HSLuv colour space: + * use photon_rs::colour_spaces::lighten_hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * lighten_hsluv(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function lighten_hsluv(img, level) { + _assertClass(img, PhotonImage); + wasm.lighten_hsluv(img.__wbg_ptr, level); +} + +/** + * Lighten an image by a specified amount in the HSV colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Lightening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to lighten an image by 10% in the HSV colour space: + * use photon_rs::colour_spaces::lighten_hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * lighten_hsv(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function lighten_hsv(img, level) { + _assertClass(img, PhotonImage); + wasm.lighten_hsv(img.__wbg_ptr, level); +} + +/** + * Lighten an image by a specified amount in the LCh colour space. + * + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to lighten the image by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Lightening by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to lighten an image by 10% in the LCh colour space: + * use photon_rs::colour_spaces::lighten_lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * lighten_lch(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function lighten_lch(img, level) { + _assertClass(img, PhotonImage); + wasm.lighten_lch(img.__wbg_ptr, level); +} + +/** + * Solarization on the Red and Green channels. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::lix; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * lix(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function lix(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.lix(photon_image.__wbg_ptr); +} + +/** + * Apply a lofi effect to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::lofi; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * lofi(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function lofi(img) { + _assertClass(img, PhotonImage); + wasm.lofi(img.__wbg_ptr); +} + +/** + * Mix image with a single color, supporting passing `opacity`. + * The algorithm comes from Jimp. See `function mix` and `function colorFn` at following link: + * https://github.com/oliver-moran/jimp/blob/29679faa597228ff2f20d34c5758e4d2257065a3/packages/plugin-color/src/index.js + * Specifically, result_value = (mix_color_value - origin_value) * opacity + origin_value = + * mix_color_value * opacity + (1 - opacity) * origin_value for each + * of RGB channel. + * + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * * `mix_color` - the color to be mixed in, as an RGB value. + * * `opacity` - the opacity of color when mixed to image. Float value from 0 to 1. + * # Example + * + * ```no_run + * // For example, to mix an image with rgb (50, 255, 254) and opacity 0.4: + * use photon_rs::Rgb; + * use photon_rs::colour_spaces::mix_with_colour; + * use photon_rs::native::open_image; + * + * let mix_colour = Rgb::new(50_u8, 255_u8, 254_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * mix_with_colour(&mut img, mix_colour, 0.4_f32); + * ``` + * @param {PhotonImage} photon_image + * @param {Rgb} mix_colour + * @param {number} opacity + */ +export function mix_with_colour(photon_image, mix_colour, opacity) { + _assertClass(photon_image, PhotonImage); + _assertClass(mix_colour, Rgb); + var ptr0 = mix_colour.__destroy_into_raw(); + wasm.mix_with_colour(photon_image.__wbg_ptr, ptr0, opacity); +} + +/** + * Apply a monochrome effect of a certain colour. + * + * It does so by averaging the R, G, and B values of a pixel, and then adding a + * separate value to that averaged value for each channel to produce a tint. + * # Arguments + * * `photon_image` - A PhotonImage. + * * `r_offset` - The value to add to the Red channel per pixel. + * * `g_offset` - The value to add to the Green channel per pixel. + * * `b_offset` - The value to add to the Blue channel per pixel. + * + * # Example + * + * ```no_run + * // For example, to apply a monochrome effect to an image: + * use photon_rs::monochrome::monochrome; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * monochrome(&mut img, 40_u32, 50_u32, 100_u32); + * ``` + * @param {PhotonImage} img + * @param {number} r_offset + * @param {number} g_offset + * @param {number} b_offset + */ +export function monochrome(img, r_offset, g_offset, b_offset) { + _assertClass(img, PhotonImage); + wasm.monochrome(img.__wbg_ptr, r_offset, g_offset, b_offset); +} + +/** + * Monochrome tint effect with increased contrast + * + * # Arguments + * * `img` - A PhotonImage. + * * `rgb_color` - RGB color + * # Example + * + * ```no_run + * use photon_rs::filters::monochrome_tint; + * use photon_rs::native::open_image; + * use photon_rs::Rgb; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgb_color = Rgb::new(12, 12, 10); + * monochrome_tint(&mut img, rgb_color); + * ``` + * @param {PhotonImage} img + * @param {Rgb} rgb_color + */ +export function monochrome_tint(img, rgb_color) { + _assertClass(img, PhotonImage); + _assertClass(rgb_color, Rgb); + var ptr0 = rgb_color.__destroy_into_raw(); + wasm.monochrome_tint(img.__wbg_ptr, ptr0); +} + +/** + * Adds multiple offsets to the image by a certain number of pixels (on two channels). + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `offset` - The offset is added to the pixels in the image. + * # Example + * + * ```no_run + * // For example, to add a 30-pixel offset to both the red and blue channels: + * use photon_rs::effects::multiple_offsets; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * multiple_offsets(&mut img, 30_u32, 0_usize, 2_usize); + * ``` + * @param {PhotonImage} photon_image + * @param {number} offset + * @param {number} channel_index + * @param {number} channel_index2 + */ +export function multiple_offsets(photon_image, offset, channel_index, channel_index2) { + _assertClass(photon_image, PhotonImage); + wasm.multiple_offsets(photon_image.__wbg_ptr, offset, channel_index, channel_index2); +} + +/** + * Solarization on the Blue channel. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::neue; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * neue(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function neue(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.neue(photon_image.__wbg_ptr); +} + +/** + * Noise reduction. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to noise reduct an image: + * use photon_rs::conv::noise_reduction; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * noise_reduction(&mut img); + * ``` + * Adds a constant to a select R, G, or B channel's value. + * @param {PhotonImage} photon_image + */ +export function noise_reduction(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.noise_reduction(photon_image.__wbg_ptr); +} + +/** + * Normalizes an image by remapping its range of pixels values. Only RGB + * channels are processed and each channel is stretched to \[0, 255\] range + * independently. This process is also known as contrast stretching. + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to turn an image of type `PhotonImage` into a normalized image: + * use photon_rs::effects::normalize; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * normalize(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function normalize(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.normalize(photon_image.__wbg_ptr); +} + +/** + * Apply a greyscale effect with increased contrast. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::obsidian; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * obsidian(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function obsidian(img) { + _assertClass(img, PhotonImage); + wasm.obsidian(img.__wbg_ptr); +} + +/** + * Adds an offset to the image by a certain number of pixels. + * + * This creates an RGB shift effect. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `channel_index`: The index of the channel to increment. 0 for red, 1 for green and 2 for blue. + * * `offset` - The offset is added to the pixels in the image. + * # Example + * + * ```no_run + * // For example, to offset pixels by 30 pixels on the red channel: + * use photon_rs::effects::offset; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * offset(&mut img, 0_usize, 30_u32); + * ``` + * @param {PhotonImage} photon_image + * @param {number} channel_index + * @param {number} offset + */ +export function offset(photon_image, channel_index, offset) { + _assertClass(photon_image, PhotonImage); + wasm.offset(photon_image.__wbg_ptr, channel_index, offset); +} + +/** + * Adds an offset to the blue channel by a certain number of pixels. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `offset_amt` - The offset you want to move the blue channel by. + * # Example + * // For example, to add an offset to the green channel by 40 pixels. + * + * ```no_run + * use photon_rs::effects::offset_blue; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * offset_blue(&mut img, 40_u32); + * ``` + * @param {PhotonImage} img + * @param {number} offset_amt + */ +export function offset_blue(img, offset_amt) { + _assertClass(img, PhotonImage); + wasm.offset_blue(img.__wbg_ptr, offset_amt); +} + +/** + * Adds an offset to the green channel by a certain number of pixels. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `offset` - The offset you want to move the green channel by. + * # Example + * + * ```no_run + * // For example, to add an offset to the green channel by 30 pixels. + * use photon_rs::effects::offset_green; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * offset_green(&mut img, 30_u32); + * ``` + * @param {PhotonImage} img + * @param {number} offset_amt + */ +export function offset_green(img, offset_amt) { + _assertClass(img, PhotonImage); + wasm.offset_green(img.__wbg_ptr, offset_amt); +} + +/** + * Adds an offset to the red channel by a certain number of pixels. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `offset` - The offset you want to move the red channel by. + * # Example + * + * ```no_run + * // For example, to add an offset to the red channel by 30 pixels. + * use photon_rs::effects::offset_red; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * offset_red(&mut img, 30_u32); + * ``` + * @param {PhotonImage} img + * @param {number} offset_amt + */ +export function offset_red(img, offset_amt) { + _assertClass(img, PhotonImage); + wasm.offset_red(img.__wbg_ptr, offset_amt); +} + +/** + * Turn an image into an oil painting + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `radius` - Radius of each paint particle + * * `intesnity` - How artsy an Image should be + * # Example + * + * ```no_run + * // For example, to oil an image of type `PhotonImage`: + * use photon_rs::effects::oil; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * oil(&mut img, 4i32, 55.0); + * ``` + * @param {PhotonImage} photon_image + * @param {number} radius + * @param {number} intensity + */ +export function oil(photon_image, radius, intensity) { + _assertClass(photon_image, PhotonImage); + wasm.oil(photon_image.__wbg_ptr, radius, intensity); +} + +/** + * Convert a HTML5 Canvas Element to a PhotonImage. + * + * This converts the ImageData found in the canvas context to a PhotonImage, + * which can then have effects or filters applied to it. + * @param {HTMLCanvasElement} canvas + * @param {CanvasRenderingContext2D} ctx + * @returns {PhotonImage} + */ +export function open_image(canvas, ctx) { + const ret = wasm.open_image(canvas, ctx); + return PhotonImage.__wrap(ret); +} + +/** + * Apply padding on the left side of the PhotonImage + * A padded PhotonImage is returned. + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `padding` - The amount of padding to be applied to the PhotonImage. + * * `padding_rgba` - Tuple containing the RGBA code for padding color. + * + * # Example + * + * ```no_run + * // For example, to apply a padding of 10 pixels on the bottom of a PhotonImage: + * use photon_rs::transform::padding_bottom; + * use photon_rs::native::open_image; + * use photon_rs::Rgba; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8); + * padding_bottom(&img, 10_u32, rgba); + * ``` + * @param {PhotonImage} img + * @param {number} padding + * @param {Rgba} padding_rgba + * @returns {PhotonImage} + */ +export function padding_bottom(img, padding, padding_rgba) { + _assertClass(img, PhotonImage); + _assertClass(padding_rgba, Rgba); + var ptr0 = padding_rgba.__destroy_into_raw(); + const ret = wasm.padding_bottom(img.__wbg_ptr, padding, ptr0); + return PhotonImage.__wrap(ret); +} + +/** + * Apply padding on the left side of the PhotonImage + * A padded PhotonImage is returned. + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `padding` - The amount of padding to be applied to the PhotonImage. + * * `padding_rgba` - Tuple containing the RGBA code for padding color. + * + * # Example + * + * ```no_run + * // For example, to apply a padding of 10 pixels on the left side of a PhotonImage: + * use photon_rs::transform::padding_left; + * use photon_rs::native::open_image; + * use photon_rs::Rgba; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8); + * padding_left(&img, 10_u32, rgba); + * ``` + * @param {PhotonImage} img + * @param {number} padding + * @param {Rgba} padding_rgba + * @returns {PhotonImage} + */ +export function padding_left(img, padding, padding_rgba) { + _assertClass(img, PhotonImage); + _assertClass(padding_rgba, Rgba); + var ptr0 = padding_rgba.__destroy_into_raw(); + const ret = wasm.padding_left(img.__wbg_ptr, padding, ptr0); + return PhotonImage.__wrap(ret); +} + +/** + * Apply padding on the left side of the PhotonImage + * A padded PhotonImage is returned. + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `padding` - The amount of padding to be applied to the PhotonImage. + * * `padding_rgba` - Tuple containing the RGBA code for padding color. + * + * # Example + * + * ```no_run + * // For example, to apply a padding of 10 pixels on the right side of a PhotonImage: + * use photon_rs::transform::padding_right; + * use photon_rs::native::open_image; + * use photon_rs::Rgba; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8); + * padding_right(&img, 10_u32, rgba); + * ``` + * @param {PhotonImage} img + * @param {number} padding + * @param {Rgba} padding_rgba + * @returns {PhotonImage} + */ +export function padding_right(img, padding, padding_rgba) { + _assertClass(img, PhotonImage); + _assertClass(padding_rgba, Rgba); + var ptr0 = padding_rgba.__destroy_into_raw(); + const ret = wasm.padding_right(img.__wbg_ptr, padding, ptr0); + return PhotonImage.__wrap(ret); +} + +/** + * Apply padding on the left side of the PhotonImage + * A padded PhotonImage is returned. + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `padding` - The amount of padding to be applied to the PhotonImage. + * * `padding_rgba` - Tuple containing the RGBA code for padding color. + * + * # Example + * + * ```no_run + * // For example, to apply a padding of 10 pixels on the top of a PhotonImage: + * use photon_rs::transform::padding_top; + * use photon_rs::native::open_image; + * use photon_rs::Rgba; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8); + * padding_top(&img, 10_u32, rgba); + * ``` + * @param {PhotonImage} img + * @param {number} padding + * @param {Rgba} padding_rgba + * @returns {PhotonImage} + */ +export function padding_top(img, padding, padding_rgba) { + _assertClass(img, PhotonImage); + _assertClass(padding_rgba, Rgba); + var ptr0 = padding_rgba.__destroy_into_raw(); + const ret = wasm.padding_top(img.__wbg_ptr, padding, ptr0); + return PhotonImage.__wrap(ret); +} + +/** + * Apply uniform padding around the PhotonImage + * A padded PhotonImage is returned. + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `padding` - The amount of padding to be applied to the PhotonImage. + * * `padding_rgba` - Tuple containing the RGBA code for padding color. + * + * # Example + * + * ```no_run + * // For example, to apply a padding of 10 pixels around a PhotonImage: + * use photon_rs::transform::padding_uniform; + * use photon_rs::native::open_image; + * use photon_rs::Rgba; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8); + * padding_uniform(&img, 10_u32, rgba); + * ``` + * @param {PhotonImage} img + * @param {number} padding + * @param {Rgba} padding_rgba + * @returns {PhotonImage} + */ +export function padding_uniform(img, padding, padding_rgba) { + _assertClass(img, PhotonImage); + _assertClass(padding_rgba, Rgba); + var ptr0 = padding_rgba.__destroy_into_raw(); + const ret = wasm.padding_uniform(img.__wbg_ptr, padding, ptr0); + return PhotonImage.__wrap(ret); +} + +/** + * Apply a rose tint to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::pastel_pink; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * pastel_pink(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function pastel_pink(img) { + _assertClass(img, PhotonImage); + wasm.pastel_pink(img.__wbg_ptr); +} + +/** + * Add pink-tinted noise to an image. + * + * **[WASM SUPPORT IS AVAILABLE]**: Randomized thread pools cannot be created with WASM, but + * a workaround using js_sys::Math::random works now. + * # Arguments + * * `name` - A PhotonImage that contains a view into the image. + * + * # Example + * + * ```no_run + * // For example, to add pink-tinted noise to an image: + * use photon_rs::native::open_image; + * use photon_rs::noise::pink_noise; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * pink_noise(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function pink_noise(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.pink_noise(photon_image.__wbg_ptr); +} + +/** + * Pixelize an image. + * + * # Arguments + * * `photon_image` - A PhotonImage that contains a view into the image. + * * `pixel_size` - Targeted pixel size of generated image. + * # Example + * + * ```no_run + * // For example, to turn an image of type `PhotonImage` into a pixelized image with 50 pixels blocks: + * use photon_rs::effects::pixelize; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * pixelize(&mut img, 50); + * ``` + * @param {PhotonImage} photon_image + * @param {number} pixel_size + */ +export function pixelize(photon_image, pixel_size) { + _assertClass(photon_image, PhotonImage); + wasm.pixelize(photon_image.__wbg_ptr, pixel_size); +} + +/** + * Apply a horizontal Prewitt convolution to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a horizontal Prewitt convolution effect: + * use photon_rs::conv::prewitt_horizontal; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * prewitt_horizontal(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function prewitt_horizontal(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.prewitt_horizontal(photon_image.__wbg_ptr); +} + +/** + * Reduces an image to the primary colours. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to add a primary colour effect to an image of type `DynamicImage`: + * use photon_rs::effects::primary; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * primary(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function primary(img) { + _assertClass(img, PhotonImage); + wasm.primary(img.__wbg_ptr); +} + +/** + * Place a PhotonImage onto a 2D canvas. + * @param {HTMLCanvasElement} canvas + * @param {CanvasRenderingContext2D} ctx + * @param {PhotonImage} new_image + */ +export function putImageData(canvas, ctx, new_image) { + _assertClass(new_image, PhotonImage); + var ptr0 = new_image.__destroy_into_raw(); + wasm.putImageData(canvas, ctx, ptr0); +} + +/** + * Convert an image to grayscale by setting a pixel's 3 RGB values to the Red channel's value. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * + * # Example + * + * ```no_run + * use photon_rs::monochrome::r_grayscale; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * r_grayscale(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function r_grayscale(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.r_grayscale(photon_image.__wbg_ptr); +} + +/** + * Remove the Blue channel's influence in an image. + * + * # Arguments + * * `img` - A PhotonImage. + * * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter. + * + * # Example + * + * ```no_run + * // For example, to remove the blue channel for blue channel pixel values less than 50: + * use photon_rs::channels::remove_blue_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * remove_blue_channel(&mut img, 50_u8); + * ``` + * @param {PhotonImage} img + * @param {number} min_filter + */ +export function remove_blue_channel(img, min_filter) { + _assertClass(img, PhotonImage); + wasm.remove_blue_channel(img.__wbg_ptr, min_filter); +} + +/** + * Set a certain channel to zero, thus removing the channel's influence in the pixels' final rendered colour. + * + * # Arguments + * * `img` - A PhotonImage. + * * `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. + * * `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 + * 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, + * then channel would be 0 and min_filter would be 50. + * + * # Example + * + * ```no_run + * // For example, to remove the Red channel with a min_filter of 100: + * use photon_rs::channels::remove_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * remove_channel(&mut img, 0_usize, 100_u8); + * ``` + * @param {PhotonImage} img + * @param {number} channel + * @param {number} min_filter + */ +export function remove_channel(img, channel, min_filter) { + _assertClass(img, PhotonImage); + wasm.remove_channel(img.__wbg_ptr, channel, min_filter); +} + +/** + * Remove the Green channel's influence in an image. + * + * # Arguments + * * `img` - A PhotonImage. + * * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter. + * + * # Example + * + * ```no_run + * // For example, to remove the green channel for green channel pixel values less than 50: + * use photon_rs::channels::remove_green_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * remove_green_channel(&mut img, 50_u8); + * ``` + * @param {PhotonImage} img + * @param {number} min_filter + */ +export function remove_green_channel(img, min_filter) { + _assertClass(img, PhotonImage); + wasm.remove_green_channel(img.__wbg_ptr, min_filter); +} + +/** + * Remove the Red channel's influence in an image. + * + * # Arguments + * * `img` - A PhotonImage. + * * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter. + * + * # Example + * + * ```no_run + * // For example, to remove the red channel for red channel pixel values less than 50: + * use photon_rs::channels::remove_red_channel; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * remove_red_channel(&mut img, 50_u8); + * ``` + * @param {PhotonImage} img + * @param {number} min_filter + */ +export function remove_red_channel(img, min_filter) { + _assertClass(img, PhotonImage); + wasm.remove_red_channel(img.__wbg_ptr, min_filter); +} + +/** + * Resample the PhotonImage. + * + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `dst_width` - Target width. + * * `dst_height` - Target height. + * + * # Example + * + * ```no_run + * // For example, to resample a PhotonImage to 1920x1080 size: + * use photon_rs::native::open_image; + * use photon_rs::transform::resample; + * + * let img = open_image("img.jpg").expect("File should open"); + * let rotated_img = resample(&img, 1920, 1080); + * ``` + * @param {PhotonImage} img + * @param {number} dst_width + * @param {number} dst_height + * @returns {PhotonImage} + */ +export function resample(img, dst_width, dst_height) { + _assertClass(img, PhotonImage); + const ret = wasm.resample(img.__wbg_ptr, dst_width, dst_height); + return PhotonImage.__wrap(ret); +} + +/** + * Resize an image. + * + * # Arguments + * * `img` - A PhotonImage. + * * `width` - New width. + * * `height` - New height. + * * `sampling_filter` - Nearest = 1, Triangle = 2, CatmullRom = 3, Gaussian = 4, Lanczos3 = 5 + * @param {PhotonImage} photon_img + * @param {number} width + * @param {number} height + * @param {SamplingFilter} sampling_filter + * @returns {PhotonImage} + */ +export function resize(photon_img, width, height, sampling_filter) { + _assertClass(photon_img, PhotonImage); + const ret = wasm.resize(photon_img.__wbg_ptr, width, height, sampling_filter); + return PhotonImage.__wrap(ret); +} + +/** + * Resize an image on the web. + * + * # Arguments + * * `img` - A PhotonImage. + * * `width` - New width. + * * `height` - New height. + * * `sampling_filter` - Nearest = 1, Triangle = 2, CatmullRom = 3, Gaussian = 4, Lanczos3 = 5 + * @param {PhotonImage} photon_img + * @param {number} width + * @param {number} height + * @param {SamplingFilter} sampling_filter + * @returns {HTMLCanvasElement} + */ +export function resize_img_browser(photon_img, width, height, sampling_filter) { + _assertClass(photon_img, PhotonImage); + const ret = wasm.resize_img_browser(photon_img.__wbg_ptr, width, height, sampling_filter); + return ret; +} + +/** + * Rotate the PhotonImage on an arbitrary angle + * A rotated PhotonImage is returned. + * + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `angle` - Rotation angle in degrees. + * + * # Example + * + * ```no_run + * // For example, to rotate a PhotonImage by 30 degrees: + * use photon_rs::native::open_image; + * use photon_rs::transform::rotate; + * + * let img = open_image("img.jpg").expect("File should open"); + * let rotated_img = rotate(&img, 30.0); + * ``` + * @param {PhotonImage} photon_img + * @param {number} angle + * @returns {PhotonImage} + */ +export function rotate(photon_img, angle) { + _assertClass(photon_img, PhotonImage); + const ret = wasm.rotate(photon_img.__wbg_ptr, angle); + return PhotonImage.__wrap(ret); +} + +/** + * ! [temp] Check if WASM is supported. + */ +export function run() { + const ret = wasm.run(); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +/** + * Solarization on the Red and Blue channels. + * + * # Arguments + * * `img` - A PhotonImage. + * # Example + * + * ```no_run + * use photon_rs::filters::ryo; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * ryo(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function ryo(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.ryo(photon_image.__wbg_ptr); +} + +/** + * Increase the image's saturation by converting each pixel's colour to the HSL colour space + * and increasing the colour's saturation. + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Increasing saturation by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to increase saturation by 10% in the HSL colour space: + * use photon_rs::colour_spaces::saturate_hsl; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * saturate_hsl(&mut img, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function saturate_hsl(img, level) { + _assertClass(img, PhotonImage); + wasm.saturate_hsl(img.__wbg_ptr, level); +} + +/** + * Increase the image's saturation in the HSLuv colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Increasing saturation by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to increase saturation by 40% in the HSLuv colour space: + * use photon_rs::colour_spaces::saturate_hsluv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * saturate_hsluv(&mut img, 0.4_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function saturate_hsluv(img, level) { + _assertClass(img, PhotonImage); + wasm.saturate_hsluv(img.__wbg_ptr, level); +} + +/** + * Increase the image's saturation in the HSV colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level by which to increase the saturation by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Increasing saturation by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to increase saturation by 30% in the HSV colour space: + * use photon_rs::colour_spaces::saturate_hsv; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * saturate_hsv(&mut img, 0.3_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function saturate_hsv(img, level) { + _assertClass(img, PhotonImage); + wasm.saturate_hsv(img.__wbg_ptr, level); +} + +/** + * Increase the image's saturation in the LCh colour space. + * # Arguments + * * `img` - A PhotonImage. + * * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by. + * The `level` must be from 0 to 1 in floating-point, `f32` format. + * Increasing saturation by 80% would be represented by a `level` of 0.8 + * + * # Example + * ```no_run + * // For example to increase saturation by 40% in the Lch colour space: + * use photon_rs::colour_spaces::saturate_lch; + * use photon_rs::native::open_image; + * + * // Open the image. A PhotonImage is returned. + * let mut img = open_image("img.jpg").expect("File should open"); + * saturate_lch(&mut img, 0.4_f32); + * ``` + * @param {PhotonImage} img + * @param {number} level + */ +export function saturate_lch(img, level) { + _assertClass(img, PhotonImage); + wasm.saturate_lch(img.__wbg_ptr, level); +} + +/** + * Resize image using seam carver. + * Resize only if new dimensions are smaller, than original image. + * # NOTE: This is still experimental feature, and pretty slow. + * + * # Arguments + * * `img` - A PhotonImage. + * * `width` - New width. + * * `height` - New height. + * + * # Example + * + * ```no_run + * // For example, resize image using seam carver: + * use photon_rs::native::open_image; + * use photon_rs::transform::seam_carve; + * use photon_rs::PhotonImage; + * + * let img = open_image("img.jpg").expect("File should open"); + * let result: PhotonImage = seam_carve(&img, 100_u32, 100_u32); + * ``` + * @param {PhotonImage} img + * @param {number} width + * @param {number} height + * @returns {PhotonImage} + */ +export function seam_carve(img, width, height) { + _assertClass(img, PhotonImage); + const ret = wasm.seam_carve(img.__wbg_ptr, width, height); + return PhotonImage.__wrap(ret); +} + +/** + * Selectively change pixel colours which are similar to the reference colour provided. + * + * Similarity between two colours is calculated via the CIE76 formula. + * Only changes the color of a pixel if its similarity to the reference colour is within the range in the algorithm. + * For example, with this function, a user can change the color of all blue pixels by mixing them with red by 10%. + * # Arguments + * * `photon_image` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * * `new_color` - The `RGB` value of the new color (to be mixed with the matched pixels) + * * `fraction` - The amount of mixing the new colour with the matched pixels + * + * # Example + * + * ```no_run + * // 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%: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_color_convert; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(200, 120, 30); + * let new_color = Rgb::new(30, 120, 200); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_color_convert(&mut img, ref_color, new_color, 0.25); + * ``` + * @param {PhotonImage} photon_image + * @param {Rgb} ref_color + * @param {Rgb} new_color + * @param {number} fraction + */ +export function selective_color_convert(photon_image, ref_color, new_color, fraction) { + _assertClass(photon_image, PhotonImage); + _assertClass(ref_color, Rgb); + var ptr0 = ref_color.__destroy_into_raw(); + _assertClass(new_color, Rgb); + var ptr1 = new_color.__destroy_into_raw(); + wasm.selective_color_convert(photon_image.__wbg_ptr, ptr0, ptr1, fraction); +} + +/** + * Selectively desaturate pixel colours which are similar to the reference colour provided. + * + * Similarity between two colours is calculated via the CIE76 formula. + * Only desaturates the hue of a pixel if its similarity to the reference colour is within the range in the algorithm. + * 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. + * # Arguments + * * `img` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * * `amt` - The amount of desaturate the colour by. + * + * # Example + * + * ```no_run + * // For example, to only desaturate the pixels that are similar to the RGB value RGB{20, 40, 60}: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_desaturate; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_desaturate(&mut img, ref_color, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {Rgb} ref_color + * @param {number} amt + */ +export function selective_desaturate(img, ref_color, amt) { + _assertClass(img, PhotonImage); + _assertClass(ref_color, Rgb); + var ptr0 = ref_color.__destroy_into_raw(); + wasm.selective_desaturate(img.__wbg_ptr, ptr0, amt); +} + +/** + * Selectively changes a pixel to greyscale if it is *not* visually similar or close to the colour specified. + * Only changes the colour of a pixel if its RGB values are within a specified range. + * + * (Similarity between two colours is calculated via the CIE76 formula.) + * 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 + * kept in the photo. + * # Arguments + * * `img` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * + * # Example + * + * ```no_run + * // For example, to greyscale all pixels that are *not* visually similar to the RGB colour RGB{20, 40, 60}: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_greyscale; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_greyscale(img, ref_color); + * ``` + * @param {PhotonImage} photon_image + * @param {Rgb} ref_color + */ +export function selective_greyscale(photon_image, ref_color) { + _assertClass(photon_image, PhotonImage); + var ptr0 = photon_image.__destroy_into_raw(); + _assertClass(ref_color, Rgb); + var ptr1 = ref_color.__destroy_into_raw(); + wasm.selective_greyscale(ptr0, ptr1); +} + +/** + * Selective hue rotation. + * + * Only rotate the hue of a pixel if its RGB values are within a specified range. + * This function only rotates a pixel's hue to another if it is visually similar to the colour specified. + * 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. + * # Arguments + * * `img` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * * `degrees` - The amount of degrees to hue rotate by. + * + * # Example + * + * ```no_run + * // For example, to only rotate the pixels that are of RGB value RGB{20, 40, 60}: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_hue_rotate; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_hue_rotate(&mut img, ref_color, 180_f32); + * ``` + * @param {PhotonImage} photon_image + * @param {Rgb} ref_color + * @param {number} degrees + */ +export function selective_hue_rotate(photon_image, ref_color, degrees) { + _assertClass(photon_image, PhotonImage); + _assertClass(ref_color, Rgb); + var ptr0 = ref_color.__destroy_into_raw(); + wasm.selective_hue_rotate(photon_image.__wbg_ptr, ptr0, degrees); +} + +/** + * Selectively lighten an image. + * + * Only lighten the hue of a pixel if its colour matches or is similar to the RGB colour specified. + * 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. + * # Arguments + * * `img` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * * `amt` - The level from 0 to 1 to lighten the hue by. Increasing by 10% would have an `amt` of 0.1 + * + * # Example + * + * ```no_run + * // For example, to only lighten the pixels that are of or similar to RGB value RGB{20, 40, 60}: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_lighten; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_lighten(&mut img, ref_color, 0.2_f32); + * ``` + * @param {PhotonImage} img + * @param {Rgb} ref_color + * @param {number} amt + */ +export function selective_lighten(img, ref_color, amt) { + _assertClass(img, PhotonImage); + _assertClass(ref_color, Rgb); + var ptr0 = ref_color.__destroy_into_raw(); + wasm.selective_lighten(img.__wbg_ptr, ptr0, amt); +} + +/** + * Selectively saturate pixel colours which are similar to the reference colour provided. + * + * Similarity between two colours is calculated via the CIE76 formula. + * Only saturates the hue of a pixel if its similarity to the reference colour is within the range in the algorithm. + * 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. + * # Arguments + * * `img` - A PhotonImage. + * * `ref_color` - The `RGB` value of the reference color (to be compared to) + * * `amt` - The amount of saturate the colour by. + * + * # Example + * + * ```no_run + * // For example, to only increase the saturation of pixels that are similar to the RGB value RGB{20, 40, 60}: + * use photon_rs::Rgb; + * use photon_rs::channels::selective_saturate; + * use photon_rs::native::open_image; + * + * let ref_color = Rgb::new(20_u8, 40_u8, 60_u8); + * let mut img = open_image("img.jpg").expect("File should open"); + * selective_saturate(&mut img, ref_color, 0.1_f32); + * ``` + * @param {PhotonImage} img + * @param {Rgb} ref_color + * @param {number} amt + */ +export function selective_saturate(img, ref_color, amt) { + _assertClass(img, PhotonImage); + _assertClass(ref_color, Rgb); + var ptr0 = ref_color.__destroy_into_raw(); + wasm.selective_saturate(img.__wbg_ptr, ptr0, amt); +} + +/** + * Convert an image to sepia. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * # Example + * + * ```no_run + * // For example, to sepia an image of type `PhotonImage`: + * use photon_rs::monochrome::sepia; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * sepia(&mut img); + * ``` + * @param {PhotonImage} img + */ +export function sepia(img) { + _assertClass(img, PhotonImage); + wasm.sepia(img.__wbg_ptr); +} + +/** + * Sharpen an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to sharpen an image: + * use photon_rs::conv::sharpen; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * sharpen(&mut img); + * ``` + * Adds a constant to a select R, G, or B channel's value. + * @param {PhotonImage} photon_image + */ +export function sharpen(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.sharpen(photon_image.__wbg_ptr); +} + +/** + * Shear the image along the X axis. + * A sheared PhotonImage is returned. + * + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `shear` - Amount to shear. + * + * # Example + * + * ```no_run + * // For example, to shear an image by 0.5: + * use photon_rs::native::open_image; + * use photon_rs::transform::shearx; + * + * let img = open_image("img.jpg").expect("File should open"); + * let sheared_img = shearx(&img, 0.5); + * ``` + * @param {PhotonImage} photon_img + * @param {number} shear + * @returns {PhotonImage} + */ +export function shearx(photon_img, shear) { + _assertClass(photon_img, PhotonImage); + const ret = wasm.shearx(photon_img.__wbg_ptr, shear); + return PhotonImage.__wrap(ret); +} + +/** + * Shear the image along the Y axis. + * A sheared PhotonImage is returned. + * + * # Arguments + * * `img` - A PhotonImage. See the PhotonImage struct for details. + * * `shear` - Amount to shear. + * + * # Example + * + * ```no_run + * // For example, to shear an image by 0.5: + * use photon_rs::native::open_image; + * use photon_rs::transform::sheary; + * + * let img = open_image("img.jpg").expect("File should open"); + * let sheared_img = sheary(&img, 0.5); + * ``` + * @param {PhotonImage} photon_img + * @param {number} shear + * @returns {PhotonImage} + */ +export function sheary(photon_img, shear) { + _assertClass(photon_img, PhotonImage); + const ret = wasm.sheary(photon_img.__wbg_ptr, shear); + return PhotonImage.__wrap(ret); +} + +/** + * Convert an image to grayscale by setting a pixel's 3 RGB values to a chosen channel's value. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `channel` - A usize representing the channel from 0 to 2. O represents the Red channel, 1 the Green channel, and 2 the Blue channel. + * + * # Example + * To grayscale using only values from the Red channel: + * ```no_run + * use photon_rs::monochrome::single_channel_grayscale; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * single_channel_grayscale(&mut img, 0_usize); + * ``` + * @param {PhotonImage} photon_image + * @param {number} channel + */ +export function single_channel_grayscale(photon_image, channel) { + _assertClass(photon_image, PhotonImage); + wasm.single_channel_grayscale(photon_image.__wbg_ptr, channel); +} + +/** + * Apply a global Sobel filter to an image + * + * Each pixel is calculated as the magnitude of the horizontal and vertical components of the Sobel filter, + * ie if X is the horizontal sobel and Y is the vertical, for each pixel, we calculate sqrt(X^2 + Y^2) + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a global Sobel filter: + * use photon_rs::conv::sobel_global; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * sobel_global(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function sobel_global(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.sobel_global(photon_image.__wbg_ptr); +} + +/** + * Apply a horizontal Sobel filter to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a horizontal Sobel filter: + * use photon_rs::conv::sobel_horizontal; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * sobel_horizontal(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function sobel_horizontal(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.sobel_horizontal(photon_image.__wbg_ptr); +} + +/** + * Apply a vertical Sobel filter to an image. + * + * # Arguments + * * `img` - A PhotonImage. + * + * # Example + * + * ```no_run + * // For example, to apply a vertical Sobel filter: + * use photon_rs::conv::sobel_vertical; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * sobel_vertical(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function sobel_vertical(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.sobel_vertical(photon_image.__wbg_ptr); +} + +/** + * Applies a solarizing effect to an image. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to colorize an image of type `PhotonImage`: + * use photon_rs::effects::solarize; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * solarize(&mut img); + * ``` + * @param {PhotonImage} photon_image + */ +export function solarize(photon_image) { + _assertClass(photon_image, PhotonImage); + wasm.solarize(photon_image.__wbg_ptr); +} + +/** + * Applies a solarizing effect to an image and returns the resulting PhotonImage. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * # Example + * + * ```no_run + * // For example, to solarize "retimg" an image of type `PhotonImage`: + * use photon_rs::effects::solarize_retimg; + * use photon_rs::native::open_image; + * use photon_rs::PhotonImage; + * + * let img = open_image("img.jpg").expect("File should open"); + * let result: PhotonImage = solarize_retimg(&img); + * ``` + * @param {PhotonImage} photon_image + * @returns {PhotonImage} + */ +export function solarize_retimg(photon_image) { + _assertClass(photon_image, PhotonImage); + const ret = wasm.solarize_retimg(photon_image.__wbg_ptr); + return PhotonImage.__wrap(ret); +} + +/** + * Swap two channels. + * + * # Arguments + * * `img` - A PhotonImage. + * * `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. + * * `channel2` - An index from 0 to 2, representing the Red, Green or Blue channels respectively. Same as above. + * + * # Example + * + * ```no_run + * // For example, to swap the values of the Red channel with the values of the Blue channel: + * use photon_rs::channels::swap_channels; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * swap_channels(&mut img, 0_usize, 2_usize); + * ``` + * @param {PhotonImage} img + * @param {number} channel1 + * @param {number} channel2 + */ +export function swap_channels(img, channel1, channel2) { + _assertClass(img, PhotonImage); + wasm.swap_channels(img.__wbg_ptr, channel1, channel2); +} + +/** + * Threshold an image using a standard thresholding algorithm. + * + * # Arguments + * * `photon_image` - A PhotonImage. + * * `threshold` - The amount the image should be thresholded by from 0 to 255. + * # Example + * + * ```no_run + * // For example, to threshold an image of type `PhotonImage`: + * use photon_rs::monochrome::threshold; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * threshold(&mut img, 30_u32); + * ``` + * @param {PhotonImage} img + * @param {number} threshold + */ +export function threshold(img, threshold) { + _assertClass(img, PhotonImage); + wasm.threshold(img.__wbg_ptr, threshold); +} + +/** + * Tint an image by adding an offset to averaged RGB channel values. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `r_offset` - The amount the R channel should be incremented by. + * * `g_offset` - The amount the G channel should be incremented by. + * * `b_offset` - The amount the B channel should be incremented by. + * # Example + * + * ```no_run + * // For example, to tint an image of type `PhotonImage`: + * use photon_rs::effects::tint; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * tint(&mut img, 10_u32, 20_u32, 15_u32); + * ``` + * @param {PhotonImage} photon_image + * @param {number} r_offset + * @param {number} g_offset + * @param {number} b_offset + */ +export function tint(photon_image, r_offset, g_offset, b_offset) { + _assertClass(photon_image, PhotonImage); + wasm.tint(photon_image.__wbg_ptr, r_offset, g_offset, b_offset); +} + +/** + * Convert a PhotonImage to JS-compatible ImageData. + * @param {PhotonImage} photon_image + * @returns {ImageData} + */ +export function to_image_data(photon_image) { + _assertClass(photon_image, PhotonImage); + var ptr0 = photon_image.__destroy_into_raw(); + const ret = wasm.to_image_data(ptr0); + return ret; +} + +/** + * Convert ImageData to a raw pixel vec of u8s. + * @param {ImageData} imgdata + * @returns {Uint8Array} + */ +export function to_raw_pixels(imgdata) { + const ret = wasm.to_raw_pixels(imgdata); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; +} + +/** + * Vertical strips. Divide an image into a series of equal-width strips, for an artistic effect. + * + * # Arguments + * * `img` - A PhotonImage that contains a view into the image. + * * `num_strips` - The numbder of strips + * # Example + * + * ```no_run + * // For example, to draw vertical strips on a `PhotonImage`: + * use photon_rs::effects::vertical_strips; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * vertical_strips(&mut img, 8u8); + * ``` + * @param {PhotonImage} photon_image + * @param {number} num_strips + */ +export function vertical_strips(photon_image, num_strips) { + _assertClass(photon_image, PhotonImage); + wasm.vertical_strips(photon_image.__wbg_ptr, num_strips); +} + +/** + * Add a watermark to an image. + * + * # Arguments + * * `img` - A DynamicImage that contains a view into the image. + * * `watermark` - The watermark to be placed onto the `img` image. + * * `x` - The x coordinate where the watermark's top corner should be positioned. + * * `y` - The y coordinate where the watermark's top corner should be positioned. + * # Example + * + * ```no_run + * // For example, to add a watermark to an image at x: 30, y: 40: + * use photon_rs::multiple::watermark; + * use photon_rs::native::open_image; + * + * let mut img = open_image("img.jpg").expect("File should open"); + * let water_mark = open_image("watermark.jpg").expect("File should open"); + * watermark(&mut img, &water_mark, 30_i64, 40_i64); + * ``` + * @param {PhotonImage} img + * @param {PhotonImage} watermark + * @param {bigint} x + * @param {bigint} y + */ +export function watermark(img, watermark, x, y) { + _assertClass(img, PhotonImage); + _assertClass(watermark, PhotonImage); + wasm.watermark(img.__wbg_ptr, watermark.__wbg_ptr, x, y); +} + +function __wbg_get_imports() { + const import0 = { + __proto__: null, + __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) { + const ret = debugString(arg1); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }, + __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) { + const ret = arg0 === undefined; + return ret; + }, + __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }, + __wbg_appendChild_dea38765a26d346d: function() { return handleError(function (arg0, arg1) { + const ret = arg0.appendChild(arg1); + return ret; + }, arguments); }, + __wbg_body_f67922363a220026: function(arg0) { + const ret = arg0.body; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) { + const ret = arg0.call(arg1); + return ret; + }, arguments); }, + __wbg_createElement_49f60fdcaae809c8: function() { return handleError(function (arg0, arg1, arg2) { + const ret = arg0.createElement(getStringFromWasm0(arg1, arg2)); + return ret; + }, arguments); }, + __wbg_data_d52fd40cc1d7d4e8: function(arg0, arg1) { + const ret = arg1.data; + const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }, + __wbg_document_ee35a3d3ae34ef6c: function(arg0) { + const ret = arg0.document; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_drawImage_00302fc1908197cc: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { + arg0.drawImage(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + }, arguments); }, + __wbg_drawImage_51b6a9d03c34c5cc: function() { return handleError(function (arg0, arg1, arg2, arg3) { + arg0.drawImage(arg1, arg2, arg3); + }, arguments); }, + __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }, + __wbg_getContext_2a5764d48600bc43: function() { return handleError(function (arg0, arg1, arg2) { + const ret = arg0.getContext(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, arguments); }, + __wbg_getImageData_24d72830c218154d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + const ret = arg0.getImageData(arg1, arg2, arg3, arg4); + return ret; + }, arguments); }, + __wbg_height_38750dc6de41ee75: function(arg0) { + const ret = arg0.height; + return ret; + }, + __wbg_height_408f385de046f7e5: function(arg0) { + const ret = arg0.height; + return ret; + }, + __wbg_height_87250db2be5164b9: function(arg0) { + const ret = arg0.height; + return ret; + }, + __wbg_instanceof_CanvasRenderingContext2d_4bb052fd1c3d134d: function(arg0) { + let result; + try { + result = arg0 instanceof CanvasRenderingContext2D; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }, + __wbg_instanceof_HtmlCanvasElement_3f2f6e1edb1c9792: function(arg0) { + let result; + try { + result = arg0 instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }, + __wbg_instanceof_Window_ed49b2db8df90359: function(arg0) { + let result; + try { + result = arg0 instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }, + __wbg_length_32ed9a279acd054c: function(arg0) { + const ret = arg0.length; + return ret; + }, + __wbg_new_8a6f238a6ece86ea: function() { + const ret = new Error(); + return ret; + }, + __wbg_new_dd2b680c8bf6ae29: function(arg0) { + const ret = new Uint8Array(arg0); + return ret; + }, + __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return ret; + }, + __wbg_new_with_u8_clamped_array_and_sh_0c0b789ceb2eab31: function() { return handleError(function (arg0, arg1, arg2, arg3) { + const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0); + return ret; + }, arguments); }, + __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) { + Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); + }, + __wbg_putImageData_78318465ad96c2c3: function() { return handleError(function (arg0, arg1, arg2, arg3) { + arg0.putImageData(arg1, arg2, arg3); + }, arguments); }, + __wbg_set_height_f21f985387070100: function(arg0, arg1) { + arg0.height = arg1 >>> 0; + }, + __wbg_set_textContent_3e87dba095d9cdbc: function(arg0, arg1, arg2) { + arg0.textContent = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2); + }, + __wbg_set_width_d60bc4f2f20c56a4: function(arg0, arg1) { + arg0.width = arg1 >>> 0; + }, + __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) { + const ret = arg1.stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }, + __wbg_static_accessor_GLOBAL_12837167ad935116: function() { + const ret = typeof global === 'undefined' ? null : global; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() { + const ret = typeof globalThis === 'undefined' ? null : globalThis; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() { + const ret = typeof self === 'undefined' ? null : self; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() { + const ret = typeof window === 'undefined' ? null : window; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_width_5901d980713eb80b: function(arg0) { + const ret = arg0.width; + return ret; + }, + __wbg_width_5f66bde2e810fbde: function(arg0) { + const ret = arg0.width; + return ret; + }, + __wbg_width_be8f36d66d37751f: function(arg0) { + const ret = arg0.width; + return ret; + }, + __wbindgen_init_externref_table: function() { + const table = wasm.__wbindgen_externrefs; + const offset = table.grow(4); + table.set(0, undefined); + table.set(offset + 0, undefined); + table.set(offset + 1, null); + table.set(offset + 2, true); + table.set(offset + 3, false); + }, + }; + return { + __proto__: null, + "./photon_rs_bg.js": import0, + }; +} + +const PhotonImageFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_photonimage_free(ptr >>> 0, 1)); +const RgbFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_rgb_free(ptr >>> 0, 1)); +const RgbaFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_rgba_free(ptr >>> 0, 1)); + +function addToExternrefTable0(obj) { + const idx = wasm.__externref_table_alloc(); + wasm.__wbindgen_externrefs.set(idx, obj); + return idx; +} + +function _assertClass(instance, klass) { + if (!(instance instanceof klass)) { + throw new Error(`expected instance of ${klass.name}`); + } +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches && builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); +} + +function getClampedArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedDataViewMemory0 = null; +function getDataViewMemory0() { + if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { + cachedDataViewMemory0 = new DataView(wasm.memory.buffer); + } + return cachedDataViewMemory0; +} + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return decodeText(ptr, len); +} + +let cachedUint8ArrayMemory0 = null; +function getUint8ArrayMemory0() { + if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { + cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8ArrayMemory0; +} + +let cachedUint8ClampedArrayMemory0 = null; +function getUint8ClampedArrayMemory0() { + if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) { + cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer); + } + return cachedUint8ClampedArrayMemory0; +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + const idx = addToExternrefTable0(e); + wasm.__wbindgen_exn_store(idx); + } +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1, 1) >>> 0; + getUint8ArrayMemory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} + +function passStringToWasm0(arg, malloc, realloc) { + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8ArrayMemory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); + const ret = cachedTextEncoder.encodeInto(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +function takeFromExternrefTable0(idx) { + const value = wasm.__wbindgen_externrefs.get(idx); + wasm.__externref_table_dealloc(idx); + return value; +} + +let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); +cachedTextDecoder.decode(); +function decodeText(ptr, len) { + return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); +} + +const cachedTextEncoder = new TextEncoder(); + +let WASM_VECTOR_LEN = 0; + +const wasmUrl = new URL('photon_rs_bg.wasm', import.meta.url); +const wasmInstantiated = await WebAssembly.instantiateStreaming(fetch(wasmUrl), __wbg_get_imports()); +const wasm = wasmInstantiated.instance.exports; +wasm.__wbindgen_start(); diff --git a/packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm b/packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm new file mode 100644 index 000000000..a9b977643 --- /dev/null +++ b/packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db2efcd06f94951a5f13736f4fc9b83c694aaa99f6699b9fbe6042d8c70d8146 +size 1939017 diff --git a/packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm.d.ts b/packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm.d.ts new file mode 100644 index 000000000..12f0e0102 --- /dev/null +++ b/packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm.d.ts @@ -0,0 +1,193 @@ +/* tslint:disable */ +/* eslint-disable */ +export const memory: WebAssembly.Memory; +export const adjust_brightness: (a: number, b: number) => void; +export const adjust_contrast: (a: number, b: number) => void; +export const color_horizontal_strips: (a: number, b: number, c: number) => void; +export const color_vertical_strips: (a: number, b: number, c: number) => void; +export const colorize: (a: number) => void; +export const dec_brightness: (a: number, b: number) => void; +export const dither: (a: number, b: number) => void; +export const duotone: (a: number, b: number, c: number) => void; +export const frosted_glass: (a: number) => void; +export const halftone: (a: number) => void; +export const horizontal_strips: (a: number, b: number) => void; +export const inc_brightness: (a: number, b: number) => void; +export const multiple_offsets: (a: number, b: number, c: number, d: number) => void; +export const normalize: (a: number) => void; +export const offset: (a: number, b: number, c: number) => void; +export const offset_blue: (a: number, b: number) => void; +export const offset_green: (a: number, b: number) => void; +export const offset_red: (a: number, b: number) => void; +export const oil: (a: number, b: number, c: number) => void; +export const pixelize: (a: number, b: number) => void; +export const primary: (a: number) => void; +export const solarize: (a: number) => void; +export const solarize_retimg: (a: number) => number; +export const tint: (a: number, b: number, c: number, d: number) => void; +export const vertical_strips: (a: number, b: number) => void; +export const apply_gradient: (a: number) => void; +export const blend: (a: number, b: number, c: number, d: number) => void; +export const create_gradient: (a: number, b: number) => number; +export const watermark: (a: number, b: number, c: bigint, d: bigint) => void; +export const b_grayscale: (a: number) => void; +export const darken_hsl: (a: number, b: number) => void; +export const darken_hsluv: (a: number, b: number) => void; +export const darken_hsv: (a: number, b: number) => void; +export const darken_lch: (a: number, b: number) => void; +export const decompose_max: (a: number) => void; +export const decompose_min: (a: number) => void; +export const desaturate: (a: number) => void; +export const desaturate_hsl: (a: number, b: number) => void; +export const desaturate_hsluv: (a: number, b: number) => void; +export const desaturate_hsv: (a: number, b: number) => void; +export const desaturate_lch: (a: number, b: number) => void; +export const draw_text: (a: number, b: number, c: number, d: number, e: number, f: number) => void; +export const draw_text_with_border: (a: number, b: number, c: number, d: number, e: number, f: number) => void; +export const g_grayscale: (a: number) => void; +export const gamma_correction: (a: number, b: number, c: number, d: number) => void; +export const grayscale: (a: number) => void; +export const grayscale_human_corrected: (a: number) => void; +export const grayscale_shades: (a: number, b: number) => void; +export const hsl: (a: number, b: number, c: number, d: number) => void; +export const hsluv: (a: number, b: number, c: number, d: number) => void; +export const hsv: (a: number, b: number, c: number, d: number) => void; +export const hue_rotate_hsl: (a: number, b: number) => void; +export const hue_rotate_hsluv: (a: number, b: number) => void; +export const hue_rotate_hsv: (a: number, b: number) => void; +export const hue_rotate_lch: (a: number, b: number) => void; +export const lch: (a: number, b: number, c: number, d: number) => void; +export const lighten_hsl: (a: number, b: number) => void; +export const lighten_hsluv: (a: number, b: number) => void; +export const lighten_hsv: (a: number, b: number) => void; +export const lighten_lch: (a: number, b: number) => void; +export const mix_with_colour: (a: number, b: number, c: number) => void; +export const monochrome: (a: number, b: number, c: number, d: number) => void; +export const r_grayscale: (a: number) => void; +export const saturate_hsl: (a: number, b: number) => void; +export const saturate_hsluv: (a: number, b: number) => void; +export const saturate_hsv: (a: number, b: number) => void; +export const saturate_lch: (a: number, b: number) => void; +export const sepia: (a: number) => void; +export const single_channel_grayscale: (a: number, b: number) => void; +export const threshold: (a: number, b: number) => void; +export const crop: (a: number, b: number, c: number, d: number, e: number) => number; +export const crop_img_browser: (a: any, b: number, c: number, d: number, e: number) => any; +export const fliph: (a: number) => void; +export const flipv: (a: number) => void; +export const padding_bottom: (a: number, b: number, c: number) => number; +export const padding_left: (a: number, b: number, c: number) => number; +export const padding_right: (a: number, b: number, c: number) => number; +export const padding_top: (a: number, b: number, c: number) => number; +export const padding_uniform: (a: number, b: number, c: number) => number; +export const resample: (a: number, b: number, c: number) => number; +export const resize: (a: number, b: number, c: number, d: number) => number; +export const resize_img_browser: (a: number, b: number, c: number, d: number) => any; +export const rotate: (a: number, b: number) => number; +export const seam_carve: (a: number, b: number, c: number) => number; +export const shearx: (a: number, b: number) => number; +export const sheary: (a: number, b: number) => number; +export const __wbg_photonimage_free: (a: number, b: number) => void; +export const __wbg_rgb_free: (a: number, b: number) => void; +export const __wbg_rgba_free: (a: number, b: number) => void; +export const base64_to_image: (a: number, b: number) => number; +export const base64_to_vec: (a: number, b: number) => [number, number]; +export const get_image_data: (a: any, b: any) => any; +export const open_image: (a: any, b: any) => number; +export const photonimage_get_base64: (a: number) => [number, number]; +export const photonimage_get_bytes: (a: number) => [number, number]; +export const photonimage_get_bytes_jpeg: (a: number, b: number) => [number, number]; +export const photonimage_get_bytes_webp: (a: number) => [number, number]; +export const photonimage_get_estimated_filesize: (a: number) => bigint; +export const photonimage_get_height: (a: number) => number; +export const photonimage_get_image_data: (a: number) => any; +export const photonimage_get_raw_pixels: (a: number) => [number, number]; +export const photonimage_get_width: (a: number) => number; +export const photonimage_new: (a: number, b: number, c: number, d: number) => number; +export const photonimage_new_from_blob: (a: any) => number; +export const photonimage_new_from_byteslice: (a: number, b: number) => number; +export const photonimage_new_from_image: (a: any) => number; +export const photonimage_set_imgdata: (a: number, b: any) => void; +export const putImageData: (a: any, b: any, c: number) => void; +export const rgb_get_blue: (a: number) => number; +export const rgb_get_green: (a: number) => number; +export const rgb_get_red: (a: number) => number; +export const rgb_new: (a: number, b: number, c: number) => number; +export const rgb_set_blue: (a: number, b: number) => void; +export const rgb_set_green: (a: number, b: number) => void; +export const rgb_set_red: (a: number, b: number) => void; +export const rgba_get_alpha: (a: number) => number; +export const rgba_new: (a: number, b: number, c: number, d: number) => number; +export const rgba_set_alpha: (a: number, b: number) => void; +export const run: () => [number, number]; +export const to_image_data: (a: number) => any; +export const to_raw_pixels: (a: any) => [number, number]; +export const rgba_get_blue: (a: number) => number; +export const rgba_get_green: (a: number) => number; +export const rgba_get_red: (a: number) => number; +export const photonimage_new_from_base64: (a: number, b: number) => number; +export const rgba_set_blue: (a: number, b: number) => void; +export const rgba_set_green: (a: number, b: number) => void; +export const rgba_set_red: (a: number, b: number) => void; +export const box_blur: (a: number) => void; +export const detect_135_deg_lines: (a: number) => void; +export const detect_45_deg_lines: (a: number) => void; +export const detect_horizontal_lines: (a: number) => void; +export const detect_vertical_lines: (a: number) => void; +export const edge_detection: (a: number) => void; +export const edge_one: (a: number) => void; +export const emboss: (a: number) => void; +export const gaussian_blur: (a: number, b: number) => void; +export const identity: (a: number) => void; +export const laplace: (a: number) => void; +export const noise_reduction: (a: number) => void; +export const prewitt_horizontal: (a: number) => void; +export const sharpen: (a: number) => void; +export const sobel_global: (a: number) => void; +export const sobel_horizontal: (a: number) => void; +export const sobel_vertical: (a: number) => void; +export const add_noise_rand: (a: number) => void; +export const alter_blue_channel: (a: number, b: number) => void; +export const alter_channel: (a: number, b: number, c: number) => void; +export const alter_channels: (a: number, b: number, c: number, d: number) => void; +export const alter_green_channel: (a: number, b: number) => void; +export const alter_red_channel: (a: number, b: number) => void; +export const alter_two_channels: (a: number, b: number, c: number, d: number, e: number) => void; +export const cali: (a: number) => void; +export const dramatic: (a: number) => void; +export const duotone_horizon: (a: number) => void; +export const duotone_lilac: (a: number) => void; +export const duotone_ochre: (a: number) => void; +export const duotone_tint: (a: number, b: number) => void; +export const duotone_violette: (a: number) => void; +export const filter: (a: number, b: number, c: number) => void; +export const firenze: (a: number) => void; +export const golden: (a: number) => void; +export const invert: (a: number) => void; +export const lix: (a: number) => void; +export const lofi: (a: number) => void; +export const monochrome_tint: (a: number, b: number) => void; +export const neue: (a: number) => void; +export const obsidian: (a: number) => void; +export const pastel_pink: (a: number) => void; +export const pink_noise: (a: number) => void; +export const remove_blue_channel: (a: number, b: number) => void; +export const remove_channel: (a: number, b: number, c: number) => void; +export const remove_green_channel: (a: number, b: number) => void; +export const remove_red_channel: (a: number, b: number) => void; +export const ryo: (a: number) => void; +export const selective_color_convert: (a: number, b: number, c: number, d: number) => void; +export const selective_desaturate: (a: number, b: number, c: number) => void; +export const selective_greyscale: (a: number, b: number) => void; +export const selective_hue_rotate: (a: number, b: number, c: number) => void; +export const selective_lighten: (a: number, b: number, c: number) => void; +export const selective_saturate: (a: number, b: number, c: number) => void; +export const swap_channels: (a: number, b: number, c: number) => void; +export const __wbindgen_malloc: (a: number, b: number) => number; +export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; +export const __wbindgen_exn_store: (a: number) => void; +export const __externref_table_alloc: () => number; +export const __wbindgen_externrefs: WebAssembly.Table; +export const __wbindgen_free: (a: number, b: number, c: number) => void; +export const __externref_table_dealloc: (a: number) => void; +export const __wbindgen_start: () => void;