Crate photon_rs

source ·
Expand description

A high-performance image processing library, available for use both natively and on the web.

Functions

96 functions are available, including:

  • Transformations: Resize, crop, and flip images.
  • 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.
  • 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.

Example

extern crate photon_rs;

use photon_rs::channels::alter_red_channel;
use photon_rs::native::{open_image};

fn main() {
    // Open the image (a PhotonImage is returned)
    let mut img = open_image("img.jpg").expect("File should open");
    // Apply a filter to the pixels
    alter_red_channel(&mut img, 25_i16);
}

This crate contains built-in preset functions, which provide default image processing functionality, as well as functions that allow for direct, low-level access to channel manipulation. To view a full demo of filtered imagery, visit the official website.

WebAssembly Use

To allow for universal communication between the core Rust library and WebAssembly, the functions have been generalised to allow for both native and in-browser use. Check out the official guide on how to get started with Photon on the web.

Live Demo

View the official demo of WASM in action.

Modules

Channel manipulation.
Image manipulation effects in HSL, HSLuv, LCh and HSV.
Convolution effects such as sharpening, blurs, sobel filters, etc.,
Special effects.
Preset color filters.
Helper functions for converting between various formats
Monochrome-related effects and greyscaling/duotoning.
Image manipulation with multiple images, including adding watermarks, changing backgrounds, etc.,
Native-only functions. Includes functions that open images from the file-system, etc.,
Add noise to images.
Draw text onto an image. For extended graphic design/text-drawing functionality, see GDL, which is a graphic design library, compatible with Photon.
Image transformations, ie: scale, crop, resize, etc.,

Structs

Provides the image’s height, width, and contains the image’s raw pixels. For use when communicating between JS and WASM, and also natively.
RGB color type.
RGBA color type.

Functions

Convert a base64 string to a PhotonImage.
Convert a base64 string to a Vec of u8s.
Get the ImageData from a 2D canvas context
Convert a HTML5 Canvas Element to a PhotonImage.
Place a PhotonImage onto a 2D canvas.
! [temp] Check if WASM is supported.
Convert a PhotonImage to JS-compatible ImageData.
Convert ImageData to a raw pixel vec of u8s.
Convert a base64 string to a PhotonImage.
Convert a base64 string to a Vec of u8s.
Get the ImageData from a 2D canvas context
Convert a HTML5 Canvas Element to a PhotonImage.
Place a PhotonImage onto a 2D canvas.
! [temp] Check if WASM is supported.
Convert a PhotonImage to JS-compatible ImageData.
Convert ImageData to a raw pixel vec of u8s.