A Flask web application that compresses images to reduce file size while maintaining quality. Upload your images and specify the target file size in KB, MB, or GB.
- 🖼️ Multiple Format Support: JPG, JPEG, PNG, GIF
- 📏 Flexible Size Targets: Compress to specific KB, MB, or GB sizes
- 🎯 Quality Optimization: Iterative compression maintains best possible quality
- 🌐 Web Interface: Easy-to-use upload and download interface
- ⚡ Fast Processing: Efficient compression algorithm
- Python 3.7 or higher
- pip (Python package installer)
-
Clone or download the repository to your local machine
-
Navigate to the project directory:
cd Image-size-compressor -
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- Linux/Mac:
source venv/bin/activate - Windows:
venv\Scripts\activate
- Linux/Mac:
-
Install required dependencies:
pip install -r requirements.txt
-
Start the Flask server:
python img_compressor.py
-
Access the application:
- Open your web browser and go to:
http://127.0.0.1:2000 - The browser should automatically open to the application
- Open your web browser and go to:
-
Using the compressor:
- Upload an image file (JPG, JPEG, PNG, or GIF)
- Specify your desired file size
- Choose the size unit (KB, MB, or GB)
- Click compress and download your optimized image
Image-size-compressor/
├── img_compressor.py # Main Flask application
├── templates/ # HTML templates
│ ├── index.html # Upload page
│ └── result.html # Download page
├── static/ # Static files
│ ├── compressed/ # Compressed images output
│ └── stylesheets/ # CSS files
├── uploads/ # Temporary upload storage
├── requirements.txt # Python dependencies
└── README.md # This file
- Framework: Flask 2.2.3
- Image Processing: Pillow (PIL) 9.5.0
- Compression Method: Iterative quality reduction
- Supported Formats: JPG, JPEG, PNG, GIF
- Target Sizes: KB, MB, GB
- Import Error: Make sure you've activated the virtual environment
- Port Already in Use: The app runs on port 2000 by default
- File Upload Issues: Check that your image is in a supported format
- Permission Errors: Ensure the
uploads/andstatic/compressed/directories are writable
Flask == 2.2.3
Werkzeug == 2.2.3
Pillow == 9.5.0



