https://github.com/x-raylaser/implementing-jpeg-compression
https://github.com/x-raylaser/implementing-jpeg-compression
dct discrete-cosine-transform discrete-fourier-transform fourier-transform hobby-project image-compression jpeg
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/x-raylaser/implementing-jpeg-compression
- Owner: X-rayLaser
- License: gpl-3.0
- Created: 2019-03-15T10:54:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-15T11:19:46.000Z (about 7 years ago)
- Last Synced: 2025-04-12T15:14:16.646Z (about 1 year ago)
- Topics: dct, discrete-cosine-transform, discrete-fourier-transform, fourier-transform, hobby-project, image-compression, jpeg
- Language: Python
- Size: 62.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Intro
The main purpose of this repository was to better understand JPEG
compression algorithm. The implementation of the
compression and decompression presented here is inefficient and far from
official JPEG standard. Therefore, it is not designed to be used for production
environment.
As of the time of this writing, the following compression steps are implemented:
subsampling, Discrete Fourier Transform/Discrete Cosine Transform,
Quantization and Run Length Encoding.
Feel free to use it for experimenting, inspiration or fun!
# Requirements
The program was tested only for Python 3.6.7
# Installation and launch
Clone the repository or download it as a zip archive.
Open a terminal.
Go inside the repository git directory (the one containing a .git folder and
requirements.txt file)
```
cd /path/to/repo
```
Go inside the repository git directory and install project's dependencies.
```
pip install -r requirements.txt
```
Compress the file with default options:
```
python compress.py in.png out
```
Decompress the file:
```
python decompress.py out reconstructed.png
```
Compress the file with subsampling factor = 5, size of DCT block = 8,
and use Discrete Cosine Transform:
```
python compress.py in.png out --block_size 5 --dct_size 8 --transform DCT
```
Compress the file with subsampling factor = 5, size of DCT block = 24,
divide each DCT quotient by 1000 (Huge compression rate):
```
python compress.py in.png out --block_size 5 --dct_size 24 --quantization divide --qdivisor 1000
```
# License
This software is licensed under GPL v3 license (see LICENSE).
## Third party libraries licenses
The software uses third party libraries that are distributed under
their own terms (see LICENSE-3RD-PARTY).