Total Complexity | 1 |
Total Lines | 15 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from PIL import Image |
||
2 | import requests |
||
3 | from io import BytesIO |
||
4 | |||
5 | |||
6 | # Get dominant color from image |
||
7 | def get_dominant_color(url): |
||
8 | response = requests.get(url) |
||
9 | pil_img = Image.open(BytesIO(response.content)) |
||
10 | img = pil_img.copy() |
||
11 | img.convert("RGB") |
||
12 | img.resize((1, 1), resample=0) |
||
13 | dominant_color = img.getpixel((0, 0)) |
||
14 | return int('%02x%02x%02x' % (dominant_color[0], dominant_color[1], dominant_color[2]), 16) |
||
15 |