To get started, install the package by following these steps:
# clone repository
git clone https://github.com/skpha13/JPEG-Compression.git
# enter the directory
cd JPEG-Compression
# install all required dependencies
pip install .This package provides a simple and intuitive CLI for compressing images.
| Command | Description |
|---|---|
-h |
Displays help information. |
--load <image_name> |
Loads a custom image for compression from the input directory. |
compress |
Compresses the currently loaded image or the default raccoon image. |
compress-to-target-mse --target-mse <value> |
Compresses the image to the specified target MSE. |
compress-video |
Compresses the video named sample_video.mp4 inside the input directory. |
To see the available commands and options, use:
python -m jpegzip.main -hTo load an image for compression, place the image in the input directory, then run:
python -m jpegzip.main --load sample_image.pngWarning
Note: The --load command is mandatory and must always come before any other commands when using custom images.
To compress an image immediately after loading:
python -m jpegzip.main --load sample_image.png compressIf no image is provided, the tool will automatically select the default raccoon image from the SciPy dataset (scipy.datasets.face).
To compress the default image:
python -m jpegzip.main compressTo compress an image while targeting a specific Mean Squared Error (MSE), use the compress-to-target-mse command.
To compress the default image with a target MSE of 100:
python -m jpegzip.main compress-to-target-mse --target-mse 100To compress a custom image (sample_image.png) with a target MSE of 100:
python -m jpegzip.main --load sample_image.png compress-to-target-mse --target-mse 100To compress the sample_video.mp4 inside the input directory.
python -m jpegzip.main compress-videoWarning
If you want to compress a custom video you will need to place it in the input directory
and rename it to sample_video.mp4.
Note
- Ensure all images you wish to process are placed in the
inputdirectory. - The compressed images will be outputted to the
outputdirectory. - Always load custom images using
--loadbefore running any compression commands.