This repository contains an API for compressing and sending images using FastAPI written in Python. The API converts a selected image to webpm and them compresses it further by encoding it with base64, while also having the option to apply extra compression methods such as algorithms like zlib.
We compare the original image (in png and jpeg format) to the webp format, which is a modern image format that provides superior compression for image files while still maintaining quality.
| Format | PNG | WEBP |
|---|---|---|
| Size | 114KB | 58KB |
| Format | JPG | Compressed WEBP |
|---|---|---|
| Size | 14.7MB | 791KB |
(Normal files used for testing are in the images directory , compressed ones are in the results directory directory)
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
You will need to have Python 3.7+ installed.
Create a new virtual environment and activate it:
python -m venv venv
. venv/bin/activateinstall dependencies with:
pip install -r requirements.txtrun api:
uvicorn main:appThis project is licensed under the MIT License - see the LICENSE.md file for details.
Made by Leonardo Lang