Color Palette Extractor

This article installs dependencies and establishes the basic functionality of color extraction from an image.

Claude Monet Springtime (1872)

1.
Install Dependencies

pip install --upgrade pip
pip install haishoku pillow

2.
API

from haishoku.haishoku import Haishoku
from PIL import Image

def new_image(mode, size, color):
    return Image.new(mode, size, color)

path = Image
# path = "https://upload.wikimedia.org/wikipedia/commons/d/dc/Yo_logo.png"

# getPalette api
palette = Haishoku.getPalette(path)

# getDominant api
# dominant = Haishoku.getDominant(path)

# showPalette api
# Haishoku.showPalette(path)

# showDominant api
dominantImage = Haishoku.showDominant(path)

# Haishoku object
h = Haishoku.loadHaishoku(path)
dominantColor = new_image('RGB', (100, 100), h.dominant)
dominantColor.save("/results/dominateColor.jpg", "JPEG")