
It is built in reference with offical typescript implementation except it's color quantization part, which is based on c++ implementation thanks to pybind.
Features
- Up to date with
material-foundation/material-color-utilities
. - Uses official c++ sources for quantization backend, which makes color generation fast!
Minimal running example:
Run file tests/test_all.py
as:
python3 test_all.py <image path> <quality>
Maximum quality is 1
that means use all pixels, and quality number more than 1
means how many pixels to skip in between while reading, also you can see it as compression.
Click to view result
Image Used, size was 8MB

Usage
Install
You can easily install it from pip by executing:
pip3 install materialyoucolor --upgrade
Prebuilt binaries are avaliable for linux
, windows
and macos
. If prebuilt binaries aren't available, then you should manually build and install.
Build and install
# Install
pip3 install https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip
OS Specific
Arch Linux
yay -S python-materialyoucolor
Thanks :heart: to @midn8hustlr for this AUR package.
Android (using kivy's buildozer
)
Ensure these lines in buildozer.spec
:
requirements = materialyoucolor
p4a.branch = develop
IOS (using kivy's kivy-ios
)
Install latest version of kivy-ios and use as:
toolchain build materialyoucolor
Usage examples
Click to show
- Generate non dynamic colors
from materialyoucolor.scheme import Scheme
from materialyoucolor.scheme.scheme_android import SchemeAndroid
color = 0xff4181EE
print(Scheme.light(color).props)
print(Scheme.dark(color).props)
print(SchemeAndroid.light(color).props)
print(SchemeAndroid.dark(color).props)
from materialyoucolor.hct import Hct
from materialyoucolor.dynamiccolor.material_dynamic_colors import MaterialDynamicColors
from materialyoucolor.scheme.scheme_tonal_spot import SchemeTonalSpot
scheme = SchemeTonalSpot(
Hct.from_int(0xff4181EE),
True,
0.0,
)
for color in vars(MaterialDynamicColors).keys():
color_name = getattr(MaterialDynamicColors, color)
if hasattr(color_name, "get_hct"):
print(color, color_name.get_hct(scheme).to_rgba())
- Generate and score colors from image
from PIL import Image
from materialyoucolor.quantize import QuantizeCelebi, ImageQuantizeCelebi
from materialyoucolor.score.score import Score
image = Image.open("path_to_some_image.jpg")
pixel_len = image.width * image.height
image_data = image.getdata()
quality = 1
pixel_array = [image_data[_] for _ in range(0, pixel_len, quality)]
result = QuantizeCelebi(pixel_array, 128)
print(result)
print(Score.score(result))
FAQ
- How it is different from
avanisubbiah/material-color-utilities
?
See https://github.com/T-Dynamos/materialyoucolor-python/issues/3