Color Manipulation and Analysis Utilities
Project description
lesColors
lesColors is a lightweight Python package that provides utilities for manipulating and analyzing colors. It includes functions for calculating adjacent, analogous, and complementary colors, converting RGB values to hexadecimal format, and extracting the dominant colors from an image via a URL.
NOTE: Major code change, previous functions remain but accessibility changed, please go through the examples.
Installation
You can install LesColors via pip:
pip install lescolors
or
pip3 install lescolors
Functions:
-
Colorclass: Provides methods for manipulating and analyzing color properties, including adjacent colors, analogous colors, complementary colors, and format conversions. -
Color.adjacent_colors(self, d: float = DEG30) -> list[Color]: Calculates and returns the adjacent colors on the color wheel for the color object. The color is adjusted by the given degree differenced(default 30 degrees). -
Color.analogous_colors(self) -> list[Color]: Computes and returns the analogous colors for the color object, which are adjacent colors on the color wheel. -
Color.complementary(self) -> Color: Computes and returns the complementary color for the color object. The complementary color is found by adding 180 degrees to the hue of the color in HSV space. -
Color.to_hex(self) -> str: Converts the color object to its hexadecimal (Hex) string format. -
Color.from_image(image_url: str, quality: int = 1) -> Color: Creates aColorobject based on the dominant color found in an image located at the given URL. -
Color.palette_from_image(image_url: str, num_colors: int = 5, quality: int = 1) -> list[Color]: Extracts and returns a palette of the most dominant RGB colors from an image located at a given URL. The number of colors is determined by thenum_colorsparameter.
Usage:
This module can be used to explore color relationships, generate color schemes, and analyze colors from images.
It is particularly useful for tasks related to dynamic theming, web development, and visual content creation.
Dependencies:
colorsys: A standard Python module for converting between color systems.requests: A Python library for making HTTP requests.colorthief: A library for grabbing the dominant color or a representative color palette from an image.
Examples:
-
Creating a
Colorobject and finding analogous colors:red = Color([255, 0, 0]) print(red.to_analogous())
-
Getting the complementary color of a color:
red = Color([255, 0, 0]) print(red.to_complementary())
-
Converting a color to Hex format:
red = Color([255, 0, 0]) print(red.to_hex())
-
Creating a color object from an image's dominant color:
dominant = Color.from_image('https://i.stack.imgur.com/JM4F2.png') print(dominant)
-
Getting a palette of dominant colors from an image:
palette = Color.palette_from_image('https://i.stack.imgur.com/JM4F2.png') print(palette)
Have suggestions or issues? Let me know!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lescolors-1.0.1.tar.gz.
File metadata
- Download URL: lescolors-1.0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e08fc5e55e7092378e81b0112b3999771f5322801bccb798415cdcfecbb65c5
|
|
| MD5 |
919661c3aa9f89efc675e903f003ebfd
|
|
| BLAKE2b-256 |
ae3ace48dc2b96c3e7644c84ac8f5861167b5667f9feb54ea517c0380ab98a86
|
File details
Details for the file lescolors-1.0.1-py3-none-any.whl.
File metadata
- Download URL: lescolors-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a91084b988d0750cc920876b02eba7d64529fedd0a094e5734c9257ed7f352d
|
|
| MD5 |
8d16a332d129935e16ac15645c5a6620
|
|
| BLAKE2b-256 |
82c5df3214a2b7eee93fc4eb9d5e075b172122e425e5d80a37aa9d1dcd98b0ae
|