Passed
Push — main ( d12a1e...942891 )
by Bartosz
02:45 queued 01:23
created

build.modules.utils   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 12
dl 0
loc 15
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
# 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