defget_accent_color(path): im = Image.open(path) if im.mode != "RGB": im = im.convert('RGB') delta_h = 0.3 avg_h = sum(t[0] for t in[colorsys.rgb_to_hsv(*im.getpixel((x,y))) for x in range(im.size[0]) for y in range(im.size[1])])/(im.size[0]*im.size[1]) beyond = filter(lambda x: abs(colorsys.rgb_to_hsv(*x)[0]- avg_h)>delta_h ,[im.getpixel((x,y)) for x in range(im.size[0]) for y in range(im.size[1])]) if len(beyond): r = sum(e[0] for e in beyond)/len(beyond) g = sum(e[1] for e in beyond)/len(beyond) b = sum(e[2] for e in beyond)/len(beyond) for i in range(im.size[0]/2): for j in range(im.size[1]/10): im.putpixel((i,j), (r,g,b)) im.save('res'+path) return r, g, b returnNone