Skip to main content

Generate themes based on an image's dominante colors

Project description

WallTheme

A color-scheme generation tool

Generates a color-scheme theme using the dominant colors of an image, inspired by pywal, wallust and (roughly) in the scheme of matugen (Material You theming).

Features

For each color retrieved from the image 2 more are generated and added to the theme. These are:

(The primary connotation depends on the relevance of the color. The most dominant color is the primary, the second is the "secondary", the third is the "tertiary", the forth is the "quaternary", the fifth is the "quinary". Further colors will just be colorN, where N is the color number)

  • primary: The original color, useful for accents;
  • primary_light: A lighter tone of the original color, useful for text and stuff in the foreground;
  • primary_dark: A darker tone of the original color, useful for containers and stuff in the background;

Also, on every theme, there are four extra fields:

  • wallpaper: The absolute path of the image provided;
  • background: A color for the background stuff based on the most dominant color (it is darker than primary_dark, optimally, it will an almost black/dark grey with a slight tint of the most dominant color);
  • foreground: A color to use in foreground stuff based on the most dominant color (it is lighter than primary_light, optimally, it will an almost white with a slight tint of the most dominant color);
  • cursor: A color to use as the cursor color. It is the exact same as foreground;

Requirements

cargo install dominant-colours

Installation

  • Install dominant-colours:
cargo install dominant-colours
  • Install WallTheme:
pipx install walltheme
  • Update WallTheme:
pipx upgrade walltheme
  • Uninstall WallTheme:
pipx uninstall walltheme
  • Uninstall dominant-colours:
cargo uninstall dominant-colours

Usage

walltheme /path/to/image.png
Args Description
-m, --max-colors Sets how many colors are used from an image (Default: 5)
-v, --version Shows the current version of WallTheme

All templates are stored in "~/.config/walltheme/templates" (or where your config directory is set in XDG);

All generated color themes are stored in "~/.cache/walltheme" (or where your cache directory is set in XDG);

Backend

The backend to find the dominant colors from images is llaisdy's dominant-colours command line tool, it IS NOT created by me.

Templates

Templates are also completely supported (with jinja2) and the following variables are available (a number of templates and an example template with multiple correct syntaxes are available in the templates folder):

  • theme: Includes all the values;
  • wallpaper: Includes the wallpaper absolute path;
  • special: Includes the background, foreground and cursor values;
  • palette: Includes all the colors;

While wallpaper is a string with a single value (i.e. can be referenced by just its name), all the other are dictionaries and require the following syntax to be referenced correctly:

All these are examples and can be used on all dictionaries variables:

  • theme.items(): References all the items in the dictionary;
  • special['background']: References the background variable in special (quotes are required);
  • palette.secondary: References the secondary variable in palette;

Why

I created this tool because the available options I found and tried never satisfied my needs completely.

Both pywal and wallust create color-schemes with colors from a provided image in pretty much any format (just have to have or create the corresponding template), but, for me, a lot of the times the order of the was seemingly random, making automation of using the color schemes the way I wanted difficult.

Matugen did choose the dominant color for the theming the grand majority of the times, but it takes into account only a single color, and the color tones of color schemes themselves are not based on the color itself, but on what the color is (red, green, blue, etc), resulting in a lot of similar looking themes and mismatching secondary and tertiary colors.

This tool (in my biased opinion), combines the best of both worlds.

TO DO

  • Add automated testing;
  • Create separate folders for each image in the cache folder, to store the themes for that image and reuse them instead of generating them each time;
  • Add a quiet argument without any output;
  • Add an argument to output the theme directly to the terminal instead of to a file (probably json only);

Project details


Download files

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

Source Distribution

walltheme-0.2.4.tar.gz (10.4 kB view details)

Uploaded Source

File details

Details for the file walltheme-0.2.4.tar.gz.

File metadata

  • Download URL: walltheme-0.2.4.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for walltheme-0.2.4.tar.gz
Algorithm Hash digest
SHA256 4cd55eec4c0688489c0fb722e67587a96d7a573d87d70fcbd7eb650fb5fd4e0c
MD5 1bcc42b91bb3e7827f1c7b38c72f6ddb
BLAKE2b-256 f562942c030e63698c1d67cfd822a2f9e0f402f1aed41345a421cd9fefec4164

See more details on using hashes here.

Supported by

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