Expand description
A lossless JPEG compressor with precise bit-for-bit recovery, supporting both baseline and progressive JPEGs. Achieves compression savings of around 22%, making it suitable for cold cloud storage use cases.
This crate is a Rust port of Dropbox’s original lepton JPEG compression tool. It retains the performance characteristics of the C++ version while benefiting from Rust’s memory safety guarantees. All JPEG content—including metadata and even malformed segments—is preserved accurately.
The original C++ codebase has been deprecated by Dropbox. This Rust implementation incorporates an exhaustive security review of the original, making it a safer and more maintainable alternative.
Structs§
- CpuTime
Measure - platform independent threadtime measurement
- Enabled
Features - Features that are enabled in the encoder. Turn off for potential backward compat issues.
- Lepton
Error - Standard error returned by Lepton library
- Lepton
File Reader - This is the state machine for the decoder for reading lepton files. The data is pushed into the state machine and processed in chuncks. Once the calculations are done the data is retrieved from the output buffers.
- Metrics
- Metrics for the Lepton JPEG compression and decompression process.
- Simple
Thread Pool - A simple thread pool that spawns threads on demand and reuses them for executing closures. There is no limit on the number of threads, but the number of idle threads is limited to the number of CPUs available.
- Single
Thread Pool - single thread pool that creates that doesn’t create any threads
Enums§
- Exit
Code - Well-defined errors for bad things that are expected to happen as part of compression/decompression
- Lepton
Thread Priority - Priority levels for threads in the thread pool.
- Thread
Pool Holder - Holds either a reference to a LeptonThreadPool or an owned Box
.
Statics§
- DEFAULT_
THREAD_ POOL - A default instance of the
SimpleThreadPoolthat can be used for encoding and decoding operations.
Traits§
- Lepton
Thread Pool - A trait that defines the interface for a Lepton thread pool. It has a simple fire-and-forget interface, which is sufficient for the current use cases, but also requires the thread pool to be static, since we don’t require the thread to return within a specific lifetime.
- Stream
Position - Trait for types that can provide the current position in a stream. This is intentionally a subset of the Seek trait, as it only requires remembering the current position without allowing seeking to arbitrary positions.
Functions§
- catch_
unwind_ result - Helper function to catch panics and convert them into the appropriate LeptonError
- decode_
lepton - Reads an entire lepton file and writes it out as a JPEG
- dump_
jpeg - used by utility to dump out the contents of a jpeg file or lepton file for debugging purposes
- encode_
lepton - Reads a jpeg and writes it out as a lepton file
- encode_
lepton_ verify - Encodes JPEG as compressed Lepton format, verifies roundtrip in buffer. Requires everything to be buffered since we need to pass through the data multiple times
- get_
git_ version - Returns the git version used to build this libary as a static string.
- get_
version_ string - Returns the version string of the library, which includes the package version and the git version. This is useful for debugging and logging purposes to know the exact version of the library is being used