A modern web application and API for converting and editing images to WebP format using FastAPI and vanilla JavaScript.
- 🖼️ Convert various image formats to WebP
- 🎨 Multiple resize modes:
- Exact size
- Percentage scaling
- Preset dimensions
- Fit within dimensions
- Fill and crop
- 📱 Common platform presets:
- HD (1280x720)
- Full HD (1920x1080)
- QHD (2560x1440)
- Instagram (1080x1080)
- Twitter (1200x675)
- Facebook (1200x630)
- Thumbnail (150x150)
- 🎯 High-quality WebP conversion with adjustable quality
- 📚 Interactive API documentation (Swagger UI)
- 🖱️ Modern drag-and-drop interface
- 👁️ Live image preview
- 📦 Uses official libwebp tools
- Python 3.8+
- libwebp 1.5.0 or higher
- pip (Python package manager)
- Nginx (for production deployment)
- Clone the repository:
git clone https://github.com/yourusername/webp-editor.git
cd webp-editor
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
- Install dependencies:
pip install -r app/requirements.txt
- Run the development server:
python app/main.py
- Open your browser and navigate to:
- Web Interface:
http://localhost:8000
- API Documentation:
http://localhost:8000/docs
- Alternative API Docs:
http://localhost:8000/redoc
- Web Interface:
- Renders the main application interface
- Returns: HTML page
- Edit image with various resize options
- Parameters:
file
: Image file (multipart/form-data)resize_mode
: One of ["exact", "percentage", "preset", "fit", "fill"]width
: Target width in pixels (for exact, fit, fill modes)height
: Target height in pixels (for exact, fit, fill modes)percentage
: Scale percentage 1-200 (for percentage mode)preset
: Predefined dimensions (for preset mode)
- Returns: JSON
{ "success": true, "message": "Image edited successfully", "image_path": "/static/uploads/image.jpg", "width": 1920, "height": 1080 }
- Convert image to WebP format
- Parameters:
file
: Image file (multipart/form-data)quality
: WebP quality 0-100 (default: 75)
- Returns: JSON
{ "success": true, "message": "Image converted successfully", "webp_path": "/static/uploads/image.webp", "width": 1920, "height": 1080 }
-
Make sure Docker and Docker Compose are installed on your system.
-
Build and start the containers:
docker-compose up -d --build
- Check the status of the containers:
docker-compose ps
- View logs:
docker-compose logs -f
- Stop the services:
docker-compose down
webp-editor/
├── app/
│ ├── static/
│ │ ├── uploads/ # Processed images
│ ├── templates/
│ │ └── index.html # Frontend interface
│ ├── main.py # FastAPI application
│ └── requirements.txt
├── deployment/
│ ├── nginx.conf
│ ├── webp-editor.service
│ └── deploy.sh
└── README.md
# TODO: Add test commands
This project follows:
- PEP 8 for Python code
- Conventional Commits for git commits
- OpenAPI standards for API documentation
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m "feat: Add some amazing feature"
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.