Python library created to obtain a specific number of dominant colors from an image.
Project description
Dominant Color Recognizer
General info
DCR is a Python library created to obtain a specific number of dominant colors from image. You can define number of colors and color model in which values will be returned.
Currently supported color models:
Color model | Example |
---|---|
HEX | #0040ff |
RGB | rgb(0, 64, 255) |
Instalation
Use the package manager pip to install DCR library:
pip install dominantcolorrecognizer
Usage
from dominant_color_recognizer import ColorAnalyzer, RGBColorModel, HEXColorModel
# RGB color model:
print(ColorAnalyzer(RGBColorModel()).get_dominant_colors('test.jpg', 3))
# You can also use URL
print(ColorAnalyzer(RGBColorModel()).get_dominant_colors('https://swiatkolorow.com.pl/userdata/public/gfx/252817/1ee9698f09e987d3e9a3785167b180b0.jpg', 3))
# Expected result:
# ["(185, 154, 90)", "(52, 40, 24)", "(25, 18, 0)"]
# HEX color model:
print(ColorAnalyzer(HEXColorModel()).get_dominant_colors('test.jpg', 3))
# Same as with RGB, you can also use URL
print(ColorAnalyzer(HEXColorModel()).get_dominant_colors('https://swiatkolorow.com.pl/userdata/public/gfx/252817/1ee9698f09e987d3e9a3785167b180b0.jpg', 3))
# Expected result:
# ['#B99A5A', '#342818', '#191200']
Tests
To run a tests you have to install pytest and run it with the command:
pytest
License
Bittapps
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
dominantcolorrecognizer-1.0.0.tar.gz
(209.6 kB
view details)
Built Distribution
File details
Details for the file dominantcolorrecognizer-1.0.0.tar.gz
.
File metadata
- Download URL: dominantcolorrecognizer-1.0.0.tar.gz
- Upload date:
- Size: 209.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.6 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94e4bde4d3e8b84e2fa92c92528b9ab0518831cb690c48ea4fcb03eaf9782d8a |
|
MD5 | 87d7f6998fc556fc1c68dbec0c1ed3da |
|
BLAKE2b-256 | 449c603fdda323f5b66a05a1be1e9ba957306861a9256c6306ebd415cfc06847 |
File details
Details for the file dominantcolorrecognizer-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: dominantcolorrecognizer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 209.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.6 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45a9c7d5022919f64d2ad07dea62899ec7c3b4e9321395ef2cc8158e3e4ae95f |
|
MD5 | f585f301e68ebc81c0e552dcc9c16678 |
|
BLAKE2b-256 | 774b37d7a2a2621fe586bffcf1df3077ad241c9ea3956777cb820094750f21a1 |