https://github.com/urigrif/jpeg-encoder
Rust command line tool that compresses images following the JPEG standard. Currently supports BMP to JPEG conversion.
https://github.com/urigrif/jpeg-encoder
bmp compression huffman-coding jpeg jpeg-encoder quantization rust subsampling
Last synced: 4 months ago
JSON representation
Rust command line tool that compresses images following the JPEG standard. Currently supports BMP to JPEG conversion.
- Host: GitHub
- URL: https://github.com/urigrif/jpeg-encoder
- Owner: uriGrif
- Created: 2024-03-19T21:12:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-13T14:00:15.000Z (6 months ago)
- Last Synced: 2024-12-29T13:57:29.153Z (6 months ago)
- Topics: bmp, compression, huffman-coding, jpeg, jpeg-encoder, quantization, rust, subsampling
- Language: Rust
- Homepage:
- Size: 110 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JPEG Encoder

## About the project
This is a simple command line tool that converts BMP image files to JPEG image files.
I made this project because I once learned how the JPEG algorithm worked and thought it was really cool and clever all the things it did to drastically reduce the size of an image, while keeping a good quality.
Moreover, it ended up being a great project to learn to code in the Rust programming language, and learning a whole lot of other interesting stuff, such as Huffman Coding, file headers and much more.

## Theory behind the code
If you want to learn how the code and the whole compression process works, you can check out [this document](jpeg_theory.md). It contains everything I learned in this project, with all the best sources I used.
## Getting started
1. Make sure you have the Rust compiler (You can get it [here](https://www.rust-lang.org))
2. Clone this repository:
```console
git clone https://github.com/uriGrif/jpeg-encoder.git
```3. Go inside the project folder and try it out
```console
cd jpeg-encoder
cargo run -- --image [OPTIONS]
``````
OPTIONS:
-i, --image
the input image path
-o, --output
the output image path (optional) [default: ]
-s, --subsampling-ratio
Subsampling ratio in the format `4:2:0`, `4:4:4`, or `4:2:2` [default: 4:2:0]
-d, --dct-algorithm
DCT algorithm to use: either "RealDct" or "BinDct" [default: real-dct] [possible values: real-dct, bin-dct]
-h, --help
Print help
-V, --version
Print version
```4. You can also build the binary and use it anywhere
```console
cargo build --release
```