Color Palette Generator from Image

Strategic Features

  • Image Quantization: The code rounds RGB values to the nearest 10. This prevents the generator from returning 6 shades of nearly identical pixels and instead picks distinct "groups" of colors.

  • Performance Optimization: Instead of scanning a high-resolution 4K image, we draw it onto a tiny $100 \times 100$ hidden canvas. This makes the extraction instant while maintaining the general color profile.

  • User Experience: Includes a "click-to-copy" feature for the HEX codes, making it immediately useful for designers.

Technical Considerations

When extracting colors, we treat each pixel as a vector in 3D space:

$$C = (R, G, B)$$

By sampling the image, we are essentially performing a simplified version of K-Means Clustering, where the most frequent "buckets" of color values are identified as the dominant palette.

Gemini Palette - Color Extractor

Color Palette Generator

Upload an image to extract its dominant color scheme.

Preview

Click or Drag Image Here