Skip to main content

Ember Colorizer

English · Español

Apply Ember color palettes to images with high precision.

Installation

uv sync

GPU acceleration (optional)

# Apple Silicon (MPS) or NVIDIA (CUDA)
pip install 'ember-colorized[gpu]'

Usage

# Auto-generated output: filename-{palette}-colorized.ext
ember-colorizer --colors=ember-light /path/to/image.png

# Custom output path
ember-colorizer --colors=ember -o /path/to/output.png /path/to/image.jpg

# Fast mode (direct RGB mapping, no K-means)
ember-colorizer --colors=ember-soft -m fast /path/to/image.png

# Adjust recolor strength (0.0 = original, 1.0 = full)
ember-colorizer --colors=ember-light -s 0.7 /path/to/image.png

# More clusters for better accuracy (aggressive mode)
ember-colorizer --colors=ember -k 20 /path/to/image.png

# Use GPU acceleration (aggressive mode only)
ember-colorizer --colors=ember --use-gpu /path/to/image.png

Palettes

Palette Background Type
ember #1c1b19 dark
ember-soft #242320 dark
ember-light #e6dac4 light
ember-lighter #e8e4de light

Modes

Aggressive mode (-m aggressive)

Uses K-means clustering to analyze the image before recoloring.

What is K-means? It's an algorithm that groups similar colors together. Imagine throwing 12 darts at a color wheel — each dart moves to the "center of gravity" of the colors closest to it. After several rounds, the darts settle on the most representative colors in the image.

How it works:

  1. K-means finds the 12 dominant colors in your image (configurable with -k)
  2. Each dominant color is mapped to its nearest Ember palette color (RGB Euclidean distance)
  3. Every pixel is reassigned to its cluster's mapped palette color
  4. Strength controls the blend between original and recolored

Result: Colors group naturally — sky areas stay coherent, skin tones stay unified. Best for photos and complex images.

Fast mode (-m fast)

Direct pixel-by-pixel RGB nearest-color mapping — no clustering, no filters. Each pixel independently maps to the closest Ember palette color using Euclidean distance in RGB space.

How it works:

  1. For each pixel, compute Euclidean distance to all palette colors in RGB space
  2. Replace the pixel with the nearest palette color

Result: Maximum detail preservation — edges, gradients, fine lines (anime hair, outlines) stay sharp. Best for anime, illustrations, line art, or when speed matters.

GPU acceleration (--use-gpu)

When --use-gpu is passed, K-means clustering runs on the GPU with smart downsampling — clusters on a 200K-pixel subset, then assigns all pixels vectorized. This greatly accelerates the recoloring time for complex, high-resolution images.

Supported backends (auto-detected):

Backend Hardware Package
cuML NVIDIA GPU cuml-cu12
PyTorch MPS Apple Silicon torch
PyTorch CUDA NVIDIA GPU torch
sklearn CPU fallback (always available)

Performance (5304×7952 image, 12 clusters):

Backend Time
CPU (sklearn) ~127s
GPU (Apple MPS) ~8s

Output example:

Input:    photo.png
Palette:  ember (Ember)
Mode:     aggressive
Strength: 1.0
GPU:      yes (Apple (arm64))
Output:   photo-ember-colorized.png
  ⠹ Clustering colors...
Success! in 7.818s

Key differences

Aggressive Fast
Algorithm K-means → cluster mapping Direct RGB nearest-color
Speed Slower (clustering pass) Fastest (vectorized)
Accuracy Higher (cluster coherence) Good (per-pixel)
Best for Photos, complex scenes Anime, illustrations, line art
Control -k clusters, -s strength -s strength only
GPU --use-gpu supported CPU only

Showcase

  • High-resolution image recoloring using GPU --use-gpu

gpu_yes

  • Same image recoloring using CPU only

gpu_no

  • Simple image recoloring using fast mode

fast_mode

As you can see, when processing a high-resolution image, GPU mode significantly accelerates the process.

This feature has been tested on Apple Silicon GPUs; it should also work on NVIDIA. If you encounter any issues with your GPU, feel free to open an issue.

License

LGPL-3.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ember_colorized-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ember_colorized-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file ember_colorized-0.1.0.tar.gz.

File metadata

  • Download URL: ember_colorized-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ember_colorized-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dc89d1c857aa3042c8f0fa8b601eaffd6b592acca5a9277a744cc6278e4ecb76
MD5 004b79e2ff5a71881cd5a15646e834dc
BLAKE2b-256 e3e9e14b9852f8944cdfc59f2cf5ad3342a4e39121fe139a264d4115b9acd532

See more details on using hashes here.

File details

Details for the file ember_colorized-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ember_colorized-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ember_colorized-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 068cc3aab0efc13f39a6e19bf5bd5361737b64c491f05a781ba7fa97e5afe325
MD5 2c43f62c85eec58e3e144929c3d6967e
BLAKE2b-256 0b1451748a6aa2b00f2cfbf8b44d477bccd66cd5aff105979c5a42134be7ebe8

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page