Skip to main content

No project description provided

Project description

PyColorPalette

PyColorPalette is a Python 3 tool capable of pulling a list of the top colors, or the color at a specific index, from a given image through the process of K-means clustering. Images can be provided either through a direct path or from a URL. Along with the RGB/Hex color value, you have the option to also retreive the percentage of the image that specific color takes up.

See examples below!

Usage

PyColorPalette derives a color palette using K-means clustering to create a cluster map. To see the cluster map use show_clustering=True. (Thank you, ZeevG)

from PyColorPalette import ColorPalette

pal = ColorPalette(r"/Users/user/Pictures/my_image.png", show_clustering=False)
#Use a raw string for Windows paths.

print(pal.get_top_colors(n=5, ratio=False, rounded=True))
# [(251, 243, 230), (101, 50, 81), (59, 18, 48), (58, 17, 47), (60, 19, 49)]

print(pal.get_color(index=3, ratio=True, rounded=True))
# ((58, 17, 47), 14)

'''
Retrieve values in hex.
'''
print(pal.get_color(index=3, ratio=True, to_hex=True, rounded=False))
# ('#3a112f', 14.1953125)

Examples

Alt text Alt text Alt text Alt text Alt text Alt text

Alt text Alt text Alt text Alt text Alt text Alt text

Alt text Alt text Alt text Alt text

Dependencies

PyColorPalette uses the Python Imaging Library (PIL) and numpy. To Install:

pip install Pillow 
pip install numpy

(Pillow and PIL cannot co-exist in the same environment. Before installing Pillow, please uninstall PIL if previosuly installed.)

Installation

pip install PyColorPalette

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

PyColorPalette-1.2.3.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file PyColorPalette-1.2.3.tar.gz.

File metadata

  • Download URL: PyColorPalette-1.2.3.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.4

File hashes

Hashes for PyColorPalette-1.2.3.tar.gz
Algorithm Hash digest
SHA256 4a3f35dfdf94e99afd046efdc04b399338ef2132165c386a2a6191780999690a
MD5 915aa48b3e65a998737ad667eb749941
BLAKE2b-256 26f859d9fb4e9a0102c8dd602589fdb9e930c2381eced8fe904d44221f134d61

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