A single-page application for image dithering with multiple algorithms and a public API. Built with Flask and React.
- Flask: Web framework for the REST API
- Pillow: Image processing library
- NumPy: Numerical computing for dithering algorithms
- Werkzeug: WSGI utility library for Python
- React: UI framework
- Vite: Build tool and development server
- TailwindCSS: Utility-first CSS framework
- Radix UI: Accessible component primitives
- JSZip: Client-side ZIP file generation
Implements four different dithering algorithms:
- Floyd-Steinberg
- Ordered Dithering
- Atkinson
- Bayer
Each algorithm is optimized for processing grayscale images using NumPy arrays for efficient computation.
-
Main Routes (
app.py
):GET /
: Serves the React applicationPOST /dither
: Processes single images
-
API Blueprint (
api.py
):POST /api/dither
: Public API endpoint for programmatic access- Supports multiple image formats: PNG, JPEG, GIF, WebP
-
DitheringPanel: Main application interface
- Handles file uploads, processing, and results display
- Manages batch processing and downloads
- Implements image preview with zoom functionality
-
Layout: Responsive application shell
- Collapsible sidebar
- Mobile-friendly navigation
Custom components built with Radix UI primitives:
- Button
- Card
- Checkbox
- Dialog
- Form elements
# Install Python dependencies
pip install pillow numpy werkzeug flask
# Install Node.js dependencies
npm install
- Start Flask backend:
python app.py
- Start Vite development server:
npm run dev
Process an image using specified dithering algorithm.
- Content-Type:
multipart/form-data
- Body:
file
: Image file (PNG, JPEG, GIF, WebP)algorithm
: String enumfloyd-steinberg
ordered
atkinson
bayer
- Success: PNG image file
- Error: JSON object with error message
{ "error": "Error description" }
- Error diffusion algorithm
- Error distribution pattern:
X 7/16 3/16 5/16 1/16
- Uses 4x4 threshold map
- Fixed pattern dithering
- Suitable for retro-style effects
- Modified error diffusion
- Distributes 1/8 of error to neighbors
- Preserves more contrast
- Ordered dithering variant
- Uses 4x4 Bayer matrix
- Produces regular pattern
- Python: Follow PEP 8
- JavaScript: ESLint with React plugin
- Use TypeScript types where available
- Feature branches from
main
- Pull requests require:
- No failing tests
- No ESLint errors
- No type errors
- Use NumPy for image processing
- Implement client-side image preview
- Batch process multiple algorithms
- Stream large file downloads
Backend tests use pytest:
pytest tests/
Frontend tests use Vitest:
npm test
MIT License