Image Compressor
A library for resizing and compressing images to jpg.
Features
- Compress and resize a single image to jpg format.
- Multithreading.
- Customize the quality and size ratio of compressed images.
- Send a completion message via
mpsc::Sender(see Using Message Passing to Transfer Data Between Threads in rust tutorial).
Supported Image Format
Visit image crate page. This crate uses image crate for opening image files.
Examples
FolderCompressor and its compress function example.
The function will compress all images, using multithreading, in a given source folder and will wait until everything is done.
If user set a Sender for FolderCompressor, the method sends messages whether compressing is complete.
use PathBuf;
use mpsc;
use FolderCompressor;
use Factor;
let source = from; // source directory path
let dest = from; // destination directory path
let thread_count = 4; // number of threads
let = channel; // Sender and Receiver. for more info, check mpsc and message passing.
let mut comp = new;
comp.set_factor;
comp.set_thread_count;
comp.set_sender;
match comp.compress
Compressor and compress_to_jpg example.
Compressing just a one image.
use PathBuf;
use Compressor;
use Factor;
let source = from.join;
let dest = from;
let comp = new;
compressor.set_factor;
comp.compress_to_jpg;