Skip to content

Instantly share code, notes, and snippets.

@zollinger
zollinger / getcolor.py
Last active November 6, 2024 08:18
Simple way to get dominant colors from an image in Python
from PIL import Image, ImageDraw
import argparse
import sys
def get_colors(image_file, numcolors=10, resize=150):
# Resize image to speed up processing
img = Image.open(image_file)
img = img.copy()
img.thumbnail((resize, resize))