Passed
Branch BonHowi (fae701)
by Bartosz
03:28
created

build.modules.utils   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 12
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A get_dominant_color() 0 8 1
1
from PIL import Image
2
import requests
3
from io import BytesIO
4
5
6
def get_dominant_color(url):
7
    response = requests.get(url)
8
    pil_img = Image.open(BytesIO(response.content))
9
    img = pil_img.copy()
10
    img.convert("RGB")
11
    img.resize((1, 1), resample=0)
12
    dominant_color = img.getpixel((0, 0))
13
    return int('%02x%02x%02x' % (dominant_color[0], dominant_color[1], dominant_color[2]), 16)
14