jippigy
A simple, multi-threaded JPEG compression crate, powered by turbojpeg.
Uses the common 2x2 chroma subsampling for compression.
Currently this crate doesn't give you finer controls over how you compress your JPEGs. Check out turbojpeg for more options.
Provides methods of compressing JPEG images in a single-threaded or multi-threaded way. Both methods preserves EXIF data of the original JPEG through img_parts crate.
1.0.1 patch
Summary:
- Parallel compressions return jpeg bytes the same order they are passed into.
- Re-exported
ParallelIntoIterator. - Minor optimizations.
See the CHANGELOG.md for more details.
Error building turbojpeg?
The problem is typically related to turbojpeg-sys (see this question and my attempt at setting up CI for this crate).
To successfully build turbojpeg-sys, you need to install cmake, a C compiler (gcc, clang, etc.), and NASM in your system (See: turbojpeg's requirements). For more details, see turbojpeg-sys's Building section.
Examples
with_ methods are optional.
Single image compressions with Single
use Single;
use ;
use Cursor;
Multi-threaded bulk compressions with Parallel
via into_iter(), Parallel converts into ParallelIntoIterator which returns items in the same order they were passed in. Which means, you can do something like the example below where you save the filenames of your JPEG into a vector, and later zip it with the ParallelIntoIterator you've made.
use Parallel;
use PathBuf;
use TempDir;
const TEST_DIR: &str = "./tests/images/";