Skip to main content

Color Manipulation and Analysis Utilities

Reason this release was yanked:

import error

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.0.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.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lescolors-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 8171e8045254f4566bb725c6da85a1e433fec40ce0dc22690a775b5f58392817
MD5 13c96a1f4066c670560468f6d997d662
BLAKE2b-256 bb86d28912bcb66051923c99434ab44e8640c55131048d981020cbf9d60fc0b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lescolors-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2ccb0a8817d67dc4f91b7caffec7ebe753e8c283f30ea81b965ca154946a533
MD5 5d12827dd323cd420781979b916d829f
BLAKE2b-256 c221a916a4c785e016fcb1a68c7d0b0aa88ac3d8047fdfc4ae68b19a6753a6af

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