This project is a tiny image manipulation library with four different functions and provides an efficient way to perform CPU intensive tasks.
It's written in Rust but is precompiled for Linux, macos and windows that can be called from a Ruby file through FFI.
Ruby setup
The project is already precompiled in three different c libraries (stored in lib/bin
) :
- librusty_engine.dll (windows)
- librusty_engine.dylib (macos)
- librusty_engine.so (linux)
Therefore if you want to use it in a ruby script you can simply install the rusty_engine
gem and simply require 'rusty_engine_ffi'
.
Usage
Converter
Example :
require 'rusty_engine_ffi'
RustyEngine.convert('images/input.jpg', 'images/output.jpg')
Arguments :
- input file path
- output path file
Slim
Example :
require 'rusty_engine_ffi'
RustyEngine.slim('images/input.jpg', 'images/output.jpg', '90', 'global', '3', 'red', '99')
Arguments :
- input file path
- output path file
- probability
- probability area
- direction
- colors
- colors probabilities
Brush
Example :
require 'rusty_engine_ffi'
RustyEngine.brush('images/input.jpg', 'images/output.jpg', '90', '5', '10', '2')
Arguments :
- input file path
- output path file
- probability
- min
- max
- direction
Pixel sorting
Example :
require 'rusty_engine_ffi'
RustyEngine.sort('images/input.jpg', 'images/output.jpg', '1', 'true', '0', '0', '30', 'true', '60', '100', '0')
Arguments :
- input file path
- output path file
- smart sorting
- detection type
- min
- max
- multiple range
- min 2
- max 2
- sorting by
Development
Project architecture
src/
contains the Rust codetarget/
contains the compiled rust code (this directory is not present in git)lib/
contains the files included in the gemlib/bin/
contains the compiled rust libraries for osx, linux and windowslib/rusty_engine.rb
is the ruby file that uses FFI to call the libraries insidelib/bin/
Compilation
To compile this project you need the following softwares installed on you machine :
For compiling the rust code for your architecture :
cargo build --release
For cross compilation, use cross :
Windows
cross build --release --target x86_64-pc-windows-gnu
Linux
cross build --release --target x86_64-unknown-linux-gnu
The compiled library is now available in the target/release/
directory.
Icon
Icons made by Freepik from www.flaticon.com