Skip to main content

Determination of the primary colors in an image file.

Project description

Determination of the primary colors in an image file.

Requirements

  • python (>=2.7.0)

  • six

  • scipy

  • numpy

  • Pillow

Installation:

$ sudo pip install primarycolors

Usage:

>>> from primarycolors import PrimaryColors
>>>
>>> # `image` - a path to image,
>>> # `max_colors` - the maximum number of colors in the resulting.
>>> im = PrimaryColors(image='Lenna.png', max_colors=5)
>>>
>>> #  The primary colors in the RGB hexadecimal list.
>>> im.hex
['621b43', '9e4257', 'e5bca5', 'd6877b', 'cb6161']
>>> im.web
['#621b43', '#9e4257', '#e5bca5', '#d6877b', '#cb6161']

>>> #  The primary colors in the RGB integer list.
>>> im.rgb
[[ 98,  27,  67], [158,  66,  87], [229, 188, 165], [214, 135, 123], [203,  97,  97]]
>>>
>>> #  An array of primary colors with the frequency coefficients.
>>> im.sorted_colors
[('cb6161', 0.24160000000000001),
 ('d6877b', 0.2412),
 ('621b43', 0.2016),
 ('9e4257', 0.1908),
 ('e5bca5', 0.12479999999999999)]
>>> im.hsl
[(326, 56.799999999999997, 24.509803921568629),
 (346, 41.071428571428569, 43.921568627450981),
 (21, 55.172413793103459, 77.254901960784323),
 (7, 52.601156069364166, 66.078431372549019),
 (0, 50.47619047619046, 58.823529411764696)]

Like command line tool

$ pcolor -i Lenna.png -w
#d68578 #c66162 #9d4459 #e3b7a2 #69234a
$ cat Lenna.png | pcolor -r
[157, 68, 89] [227, 183, 162] [214, 133, 120] [105, 35, 74] [198, 97, 98]

License:

primarycolors is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

primary colors is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with primarycolors. If not, see http://www.gnu.org/licenses/.

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

primarycolors-0.6.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

primarycolors-0.6.3-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file primarycolors-0.6.3.tar.gz.

File metadata

  • Download URL: primarycolors-0.6.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for primarycolors-0.6.3.tar.gz
Algorithm Hash digest
SHA256 6fec021f44a75f6e1f36a398058bac54a3f7038d3ee3afcae36b66fa8bfc4be2
MD5 63b6366ed6ed2d945dae298dd04f8183
BLAKE2b-256 e5d20c83f28eb46dc29fc886428416c34c4c3300797fc4e9008b749ef577d9c6

See more details on using hashes here.

File details

Details for the file primarycolors-0.6.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for primarycolors-0.6.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 aad33e19a1259a60840f5af7bd63fabdfc486efaeebf7ba59ff67c993e51f61f
MD5 9e87a27584b863b83b7c804c4001c27a
BLAKE2b-256 6531ff285aa3ff05ec6b3c1266908e8fc35f9a6e509bb98cf41168bae7d7ef62

See more details on using hashes here.

Supported by

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