Skip to main content

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:

  • Color class: 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 difference d (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 a Color object 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 the num_colors parameter.

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 Color object 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


Download files

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

Source Distribution

lescolors-1.0.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

lescolors-1.0.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file lescolors-1.0.2.tar.gz.

File metadata

  • Download URL: lescolors-1.0.2.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

Hashes for lescolors-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a6668cf6400984ffec876b618bb26bdf34592edfccd53dbe86b83c08ba1b73d2
MD5 4f26c7ce5e9bd0fcff015eee6795571f
BLAKE2b-256 4d43edb631aba719d3cad7ff7e2e57fd2964e5c6717a6cb251b5af632105aff0

See more details on using hashes here.

File details

Details for the file lescolors-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: lescolors-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.0

File hashes

Hashes for lescolors-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c6c00268ade54ad903196972faef619f7d0353b088eaf153f499e18f2d84883
MD5 574ec02276863c8656d717c6c1f36698
BLAKE2b-256 54c0d2657b2630d9bcb90fdaa6f01693aaaa8b4abf4aa86d5cf4d40393285a13

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