UNPKG

azion

Version:

Azion Packages for Edge Computing.

1,571 lines (1,495 loc) 121 kB
/** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {InitInput | Promise<InitInput>} module_or_path * * @returns {Promise<InitOutput>} */ declare function __wbg_init(module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>; /** * 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 */ declare function add_noise_rand(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image * @param {number} contrast */ declare function adjust_contrast(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} amt */ declare function alter_blue_channel(img: PhotonImage_2, 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. * @param {PhotonImage} img * @param {number} channel * @param {number} amt */ declare function alter_channel(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} r_amt * @param {number} g_amt * @param {number} b_amt */ declare function alter_channels(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} amt */ declare function alter_green_channel(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} photon_image * @param {number} amt */ declare function alter_red_channel(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} channel1 * @param {number} amt1 * @param {number} channel2 * @param {number} amt2 */ declare function alter_two_channels( img: PhotonImage_2, channel1: number, amt1: number, channel2: number, amt2: number, ): void; /** * Apply a gradient to an image. * @param {PhotonImage} image */ declare function apply_gradient(image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function b_grayscale(photon_image: PhotonImage_2): void; /** * Convert a base64 string to a PhotonImage. * @param {string} base64 * @returns {PhotonImage} */ declare function base64_to_image(base64: string): PhotonImage_2; /** * Convert a base64 string to a Vec of u8s. * @param {string} base64 * @returns {Uint8Array} */ declare 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`, `multiply`, `burn`, `soft_light`, `hard_light`, * `difference`, `lighten`, `darken`, `dodge`, `plus`, `exclusion` (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 */ declare function blend(photon_image: PhotonImage_2, photon_image2: PhotonImage_2, 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); * ``` * @param {PhotonImage} photon_image */ declare function box_blur(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} img */ declare function cali(img: PhotonImage_2): void; /** * Cleans up resources associated with the image. * @param {photon.PhotonImage} image - The image to clean up. */ export declare function clean(image: photon.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); * ``` * @param {PhotonImage} photon_image * @param {number} num_strips * @param {Rgb} color */ declare function color_horizontal_strips(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} photon_image * @param {number} num_strips * @param {Rgb} color */ declare function color_vertical_strips(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} photon_image */ declare function colorize(photon_image: PhotonImage_2): void; /** * @param {number} width * @param {number} height * @returns {PhotonImage} */ declare function create_gradient(width: number, height: number): PhotonImage_2; /** * 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(&mut 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} */ declare function crop(photon_image: PhotonImage_2, x1: number, y1: number, x2: number, y2: number): PhotonImage_2; /** * @param {HTMLCanvasElement} source_canvas * @param {number} width * @param {number} height * @param {number} left * @param {number} top * @returns {HTMLCanvasElement} */ declare 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); * ``` * @param {PhotonImage} img * @param {number} level */ declare function darken_hsl(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} level */ declare function darken_hsluv(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} level */ declare function darken_hsv(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} level */ declare function darken_lch(img: PhotonImage_2, level: 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); * ``` * @param {PhotonImage} img */ declare function decompose_max(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} img */ declare function decompose_min(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} img */ declare function desaturate(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} img * @param {number} level */ declare function desaturate_hsl(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} level */ declare function desaturate_hsluv(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} level */ declare function desaturate_hsv(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} level */ declare function desaturate_lch(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} photon_image */ declare function detect_135_deg_lines(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function detect_45_deg_lines(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function detect_horizontal_lines(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function detect_vertical_lines(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image * @param {number} depth */ declare function dither(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} img */ declare function dramatic(img: PhotonImage_2): 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. * * # 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); * ``` * @param {PhotonImage} photon_img * @param {string} text * @param {number} x * @param {number} y */ declare function draw_text(photon_img: PhotonImage_2, text: string, x: number, y: 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. * * # 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); * ``` * @param {PhotonImage} photon_img * @param {string} text * @param {number} x * @param {number} y */ declare function draw_text_with_border(photon_img: PhotonImage_2, text: string, x: number, y: number): void; /** * @param {PhotonImage} photon_image * @param {Rgb} color_a * @param {Rgb} color_b */ declare function duotone(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} img */ declare function duotone_horizon(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} img */ declare function duotone_lilac(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} img */ declare function duotone_ochre(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} img * @param {Rgb} rgb_color */ declare function duotone_tint(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img */ declare function duotone_violette(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function edge_detection(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function edge_one(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function emboss(photon_image: PhotonImage_2): 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"); * ``` * @param {PhotonImage} img * @param {string} filter_name */ declare function filter(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img */ declare function firenze(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function fliph(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function flipv(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function frosted_glass(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image */ declare function g_grayscale(photon_image: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image * @param {number} red * @param {number} green * @param {number} blue */ declare function gamma_correction(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} photon_image * @param {number} radius */ declare function gaussian_blur(photon_image: PhotonImage_2, radius: number): void; /** * Get the ImageData from a 2D canvas context * @param {HTMLCanvasElement} canvas * @param {CanvasRenderingContext2D} ctx * @returns {ImageData} */ declare function get_image_data(canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D): ImageData; /** * Gets the image as a Response object in the specified format. */ export declare function getImageResponse(image: photon.PhotonImage, format: SupportedImageFormat, quality?: number): Response; /** * 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 */ declare function golden(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} img */ declare function grayscale(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} img */ declare function grayscale_human_corrected(img: PhotonImage_2): 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); * ``` * @param {PhotonImage} photon_image * @param {number} num_shades */ declare function grayscale_shades(photon_image: PhotonImage_2, num_shades: number): 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); * ``` * @param {PhotonImage} photon_image * @param {number} num_strips */ declare function horizontal_strips(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} photon_image * @param {string} mode * @param {number} amt */ declare function hsl(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} photon_image * @param {string} mode * @param {number} amt */ declare function hsluv(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} photon_image * @param {string} mode * @param {number} amt */ declare function hsv(photon_image: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} degrees */ declare function hue_rotate_hsl(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} degrees */ declare function hue_rotate_hsluv(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} degrees */ declare function hue_rotate_hsv(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} img * @param {number} degrees */ declare function hue_rotate_lch(img: PhotonImage_2, 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); * ``` * @param {PhotonImage} photon_image */ declare function identity(photon_image: PhotonImage_2): void; /** * Increase the brightness of an image by a factor. * * # 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 */ declare function inc_brightness(photon_image: PhotonImage_2, brightness: number): void; declare type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; declare interface InitOutput { readonly memory: WebAssembly.Memory; readonly __wbg_photonimage_free: (a: number) => void; readonly photonimage_new: (a: number, b: number, c: number, d: number) => number; readonly photonimage_new_from_byteslice: (a: number, b: number) => number; readonly photonimage_new_from_blob: (a: number) => number; readonly photonimage_new_from_image: (a: number) => number; readonly photonimage_get_width: (a: number) => number; readonly photonimage_get_raw_pixels: (a: number, b: number) => void; readonly photonimage_get_height: (a: number) => number; readonly photonimage_get_base64: (a: number, b: number) => void; readonly photonimage_get_bytes: (a: number, b: number) => void; readonly photonimage_get_bytes_jpeg: (a: number, b: number, c: number) => void; readonly photonimage_get_bytes_webp: (a: number, b: number) => void; readonly photonimage_get_image_data: (a: number) => number; readonly photonimage_set_imgdata: (a: number, b: number) => void; readonly __wbg_rgb_free: (a: number) => void; readonly rgb_new: (a: number, b: number, c: number) => number; readonly rgb_set_red: (a: number, b: number) => void; readonly rgb_set_green: (a: number, b: number) => void; readonly rgb_set_blue: (a: number, b: number) => void; readonly rgb_get_red: (a: number) => number; readonly rgb_get_green: (a: number) => number; readonly rgb_get_blue: (a: number) => number; readonly rgba_new: (a: number, b: number, c: number, d: number) => number; readonly rgb