Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://silvia-odwyer.github.io/photon/
⚡ Rust/WebAssembly image processing library
https://silvia-odwyer.github.io/photon/
hacktoberfest image-manipulation image-processing rust rust-library wasm webassembly
Last synced: about 11 hours ago
JSON representation
⚡ Rust/WebAssembly image processing library
- Host: GitHub
- URL: https://silvia-odwyer.github.io/photon/
- Owner: silvia-odwyer
- License: apache-2.0
- Created: 2019-02-13T19:46:04.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-31T19:48:42.000Z (14 days ago)
- Last Synced: 2024-11-08T07:44:39.094Z (7 days ago)
- Topics: hacktoberfest, image-manipulation, image-processing, rust, rust-library, wasm, webassembly
- Language: Rust
- Homepage: https://silvia-odwyer.github.io/photon
- Size: 69.2 MB
- Stars: 2,710
- Watchers: 39
- Forks: 154
- Open Issues: 46
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Security: SECURITY.md
Awesome Lists containing this project
- Awesome-WebAssembly-Applications - [Photon
README
# photon
Photon
[![Status](https://img.shields.io/badge/status-active-success.svg?style=for-the-badge&logo=statuspal)]()
[![GitHub Issues](https://img.shields.io/github/issues/silvia-odwyer/photon.svg?style=for-the-badge&logo=github)](https://github.com/silvia-odwyer/photon/issues)
[![Gitter Chat](https://img.shields.io/gitter/room/silvia-odwyer/photon?color=cyan&logo=Gitter&style=for-the-badge)](https://gitter.im/photonlibrary/community "Gitter chat")
[![NPM Monthly Downloads](https://img.shields.io/npm/dm/@silvia-odwyer/photon?logo=npm&style=for-the-badge&color=pink)](https://www.npmjs.com/package/@silvia-odwyer/photon)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/silvia-odwyer/photon/ci.yml?branch=master&logo=github&style=for-the-badge)](https://github.com/silvia-odwyer/photon/blob/master/.github/workflows/compile_wasm.yaml)[![Crates.io](https://img.shields.io/crates/v/photon_rs?logo=rust&style=for-the-badge)](https://crates.io/crates/photon_rs)
[![License](https://img.shields.io/github/license/silvia-odwyer/photon?style=for-the-badge)](https://github.com/silvia-odwyer/photon/blob/master/LICENSE.md)
[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/silvia-odwyer/photon.svg?style=for-the-badge&logo=github-actions)](https://github.com/silvia-odwyer/photon/pulls)---
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#get-started-natively)
- [Documentation](https://docs.rs/photon-rs/)
- [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.You can run Photon:
- natively
- in the browser with WebAssembly
- on Node with WebAssembly### Features
- **Fast:** On the web, Photon's high-performance allows it to run at near-native speed. Benchmarks can be found [here](https://github.com/silvia-odwyer/photon/wiki/Benchmarks).
- **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.
- **Pure Rust** - Unlike other libraries, 100% of the library's codebase is written in Rust, so security and safety is guaranteed.### Live Demo
View the [official demo of WASM in action](https://silvia-odwyer.github.io/photon/demo.html).### Photon In Action
![Imgur](https://i.imgur.com/PShSZ6k.png)
### Version 0.3.2 Release [2023 Update]
Version 0.3.2 has been released on Crates.io and NPM, with new features including:- A duotone filter and preset duotone effects
- Image rotation
- Dithering filter
- Image cropping update (fixed in [PR #100](https://github.com/silvia-odwyer/photon/pull/100))### Supported Image Formats
The following image formats are supported:- PNG
- JPEG
- BMP
- ICO
- TIFF
- WEBP### 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
View the [official documentation](https://docs.rs/photon-rs/).### Functions
96 customisable functions are available, for varying image effects.Functions include:
- **Image correction**: Hue rotation, sharpening, brightness adjustment, adjusting saturation, lightening/darkening all within various colour spaces.
- **Resizing**: Resize images both natively and on the web.
- **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**: Monochrome tints, 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.
- **Watermarking**: Watermark images in multiple formats.
- **Blending**: Blend images together using 10 different techniques, change image backgrounds.## Get Started Natively
### Install
Add the following line to the dependencies section of your Rust project's Cargo.toml:###### Cargo.toml
```toml
[dependencies]
photon-rs = "0.3.2"
```#### Using Photon Natively
The following code opens an image from the filesystem, applies an effect, and outputs it as a PNG.Here is a code sample to get you started:
```rust
extern crate photon_rs;
use photon_rs::native::{open_image, save_image};fn main() -> Result<(), Box> {
// 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")?;Ok(())
}
```##### See More Examples
[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/)### Building WebAssembly package
In order to build the WebAssembly package you will need `wasm-pack`. Check https://rustwasm.github.io/wasm-pack/installer/ on how to install it. Then you can run the command:
```bash
wasm-pack build ./crate
```## Get Started With WebAssembly
### Using a Bundler?
#### Installing Photon
If you're using Webpack or a bundler to build your project, install Photon via [npm](https://www.npmjs.com/package/@silvia-odwyer/photon):```bash
npm install @silvia-odwyer/photon
```You can run Photon directly in any web browser that supports WebAssembly, which includes Chrome, Firefox, Safari, and Edge.
##### Get Started with Photon on The Web
To get started, [check out the guide](https://silvia-odwyer.github.io/photon/guide/using-photon-web/).#### Using NodeJS?
If you're intending to use Photon with NodeJS, you can install the NodeJS version of the library:```bash
npm install @silvia-odwyer/photon-node
```#### Using Cloudflare Workers?
If you're using Cloudflare Workers, you can install the following library to use Photon with Cloudflare Workers:```bash
npm install @cf-wasm/photon
```## 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.### Quick Start Example
Clone this repo:
```sh
git clone https://github.com/silvia-odwyer/photon
```Run the binary, which will perform an image processing function on an image:
```sh
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 have further questions about this library, you can ask them on [Gitter](https://gitter.im/photonlibrary/community) or [Spectrum](https://spectrum.chat/photonlibrary), and I'll get back to you!If there are any issues involving running/using the library, make sure to open an issue, it would be greatly appreciated,
and will help improve the library.- [Spectrum](https://spectrum.chat/photonlibrary)
- [Gitter](https://gitter.im/photonlibrary/community)## Additional Notes
Functions have been designed with flexibility in mind, so that full customization of effects and filters can be utilised; for every function, hundreds of differing image effects/tints/hues can be created, just by changing parameters slightly, so with every function comes the ability to fully experiment.For developers who would like to work with high-level constructs can do so, such as applying effects to imagery (eg: Laplace or Sobel)
or filters; this library provides a complete suite of functions to do so, as well as in-built filters and presets.`photon` can be thought of as a high-level wrapper to the Rust `image` crate, but conversely also includes functions which provide low-level access to pixel and channel manipulation, perfect for developers who wish to work with this data directly.
## Contributing
Photon is always accepting new filters and functions. In that vein if you'd like to contribute to Photon please submit a Pull Request or add new issues for investigation. Our community is our lifeblood, and we appreciate all the support we get from individuals like you.
## To Do
- Blend images using browser-specific functions for WASM version of library.
- Vintage images with light leaks, grains, etc.,
- Tests in a headless web browser for WebAssembly version of library## Contributors
This repository continually receives new filters and updates from fellow contributors, for which I'm very grateful for! Thanks to the generous contributions of others, there are even more cool effects available in this library.I'd like to extend my gratitude to all of you!
Contributors include (be sure to add yourself to the list if you submitted a PR):
* **Silvia O'Dwyer** - [@silvia-odwyer](https://github.com/silvia-odwyer)
* **Osman Turan** - [@osman-turan](https://github.com/osman-turan)
* **Ivan Zvonimir Horvat** - [@Horki](https://github.com/Horki)
* **Arnav Jindal** - [@Daggy1234](https://github.com/Daggy1234)
* **NorbertGarfield** - [@NorbertGarfield](https://github.com/NorbertGarfield)
* **bboshoven** - [@bboshoven](https://github.com/bboshoven)
* **benliao** - [@benliao](https://github.com/benliao)
* **Fineshop Design** - [@fineshop](https://github.com/fineshop)
* **volbot** - [@volbot](https://github.com/volbot)
* **Future You(?)** - (See Contributing above)## License
This project is licensed under the Apache 2.0 License - see the [LICENSE.md](LICENSE.md) file for details.