API Differences¶
Overview
This page documents the output differences between modern_colorthief
and the original color-thief (JavaScript/Python) library.
Comparison with color-thief
The difference between color-thief and modern_colorthief is very
negligible. Both use the same Median Cut algorithm, so results are nearly
identical.
Example Comparison
Using the following test code:
Comparison test¶
1from modern_colorthief import get_color, get_palette
2from colorthief import ColorThief
3from pathlib import Path
4import os
5
6BASE_DIR = Path(__file__).resolve().parent
7path = os.path.join(BASE_DIR, "test.jpg")
8
9print(path)
10
11x = get_color(path)
12y = ColorThief(path).get_color()
13
14print(x)
15print(y)
16
17m = get_palette(path)
18n = ColorThief(path).get_palette()
19
20print(m)
21print(n)
The output is:
Output comparison¶
1# modern_colorthief dominant color
2(201, 160, 118)
3
4# colorthief dominant color
5(202, 160, 118)
6
7# modern_colorthief palette
8[(30, 169, 166), (179, 51, 55), (219, 176, 127), (248, 233, 225),
9 (160, 98, 87), (63, 47, 42), (131, 163, 107), (179, 119, 52),
10 (237, 220, 155)]
11
12# colorthief palette
13[(31, 167, 164), (179, 51, 55), (219, 176, 127), (248, 233, 225),
14 (160, 98, 87), (62, 44, 38), (131, 162, 106), (178, 118, 51),
15 (242, 220, 157)]
Note
For most practical purposes (UI theming, color analysis, design tools), these differences are imperceptible.
See also
Differences – Broader comparison with other libraries.