Upload an image, get its top 10 colors as HEX codes.
Palette is a Flask web app that analyzes any uploaded image and extracts its 10 most common colors, displayed as clickable swatch cards with their HEX codes. All the color analysis happens with Numpy pixel counting, no external API, no machine learning model, just fast, straightforward array math.
- 📁 Drag-and-drop or click-to-upload image interface
- 🎨 Top 10 dominant colors, extracted via Numpy pixel frequency analysis
- 🟩 Swatch grid display — each color shown as a card with its live color swatch and HEX code
- 📋 Click-to-select HEX codes (
user-select: all) for instant copying - 🔁 Session-based results — the analyzed image's colors persist through a redirect, then clear automatically afterward
- 🎨 Minimal dark-themed interface
- Python 3 + Flask — routing, file uploads, and session handling
- Pillow (PIL) — opening and resizing the uploaded image
- NumPy — counting and ranking pixel colors by frequency
- HTML5 / CSS3 — custom-styled frontend, no CSS framework
- Google Fonts — JetBrains Mono (headings) & Inter (body)
palette/
├── app.py # Flask application (upload handling + color analysis)
├── uploads/ # Auto-created folder where uploaded images are saved
├── templates/
│ └── index.html # Main page template (Jinja2)
├── static/
│ └── style.css # Stylesheet
└── README.md
Note: The
uploads/folder is created automatically the first time the app runs (os.makedirs(UPLOAD_FOLDER, exist_ok=True)), so it doesn't need to exist in the repo beforehand.
pip install flask pillow numpy
git clone https://github.com/rhitamcoder/palette.git
cd palette
python app.py
The app will start in debug mode at http://127.0.0.1:5000/. Upload an image, click Find Colors, and see its top 10 dominant colors appear below.
- Upload: the image is saved to the
uploads/folder via the/analyzePOST route - Resize: the image is downscaled to 150×150 pixels for fast analysis, since exact color accuracy doesn't require full resolution
- Flatten: the image is converted into a flat array of RGB pixel values using NumPy
- Count:
np.unique()identifies every distinct color and how many times it appears - Rank: the 10 most frequent colors are selected and converted to HEX format
- Display: the HEX codes are stored in the session, and the home page reads and clears them on render, so results show once per upload
app.py sets app.secret_key = "image-hex", a hardcoded value used only to sign Flask's session cookie (no external API or account is tied to this key). It's fine for local use and demonstration purposes, but if this app were ever deployed publicly, this should be replaced with a securely generated random key loaded from an environment variable.
This project is licensed under the MIT License — see the LICENSE file for details.