Image Processing in WebAssembly
Photon is a high-performance image processing library in WebAssembly that runs both natively and on the web.
Photon is a high-performance image processing library in WebAssembly that runs both natively and on the web.
Photon outperforms even the fastest of libraries, and is powered with Rust, allowing for safe and secure image processing.
For web-based image processing, Photon is 4-10x faster than JS, leading to faster results, and less lag.
Photon provides functions for every domain of image processing.
This library's WASM functions can be called via JS, allowing for zero-cost abstraction and faster development.
Photon can be executed:
Photon compiles to WebAssembly, which allows the execution of native-speed code in the browser and on Node.JS. This leads to high-performance image processing on the web and since Photon's core library is written in Rust, it promises security and safety.
Photon's core library is a Rust crate, available from Cargo.
Write code in JS without a single line of Rust.
JS code gets exported to WebAssembly.
Photon outperforms even the fastest of libraries, both natively and on the web.
For full benchmark results, check them out here.
Photon has greatly outperformed ImageMagick and the Python Imaging Library, as shown in the graph to the right, and is on par with libvips.
As for the web, the browser can take advantage of WebAssembly's near-native performance to deliver blazing-fast image processing on the client-side, thus sparing you the need to process images server-side.
Photon provides low-level access to pixel and channel manipulation, as well as high-level functions for image correction, filtering, watermarking, and convolutions.
Resize images at lightning-speeds.
High-performance image resizing with 5 different resizing algorithms to choose from, so that you can choose the algorithm most suited to your use case.
Adjust images by correcting brightness, saturation, hues, and more, all within various colour spaces. This gives full flexibility to work in many colour spaces, leading to improved results tailored to your image.
Photon comes with a variety of built-in effects, including:
Functions include:
Blending:Blend images together using 10 different techniques.
Create new images from existing ones, or create new worlds from source images.
To see WebAssembly in action and all effects available, make sure to check out our demo , where you can test out the effects, view performance, and see if Photon is the right library for your website.
You can transform an image in just 3 lines of code, either in JS or Rust, whichever your choice may be.
To compare JavaScript vs WebAssembly, click on one of the buttons below to see the right-hand side image edited by either JavaScript or WebAssembly.
The time taken to edit the image will be displayed below.
JS time:
WASM time:
If you have any questions, want to chat about your potential use case, or want help in getting started with Photon, be sure to shoot me a message on Spectrum or Gitter.