def PILColorToRGB(pil_color):
    """ convert a PIL-compatible integer into an (r, g, b) tuple """
    hexstr = '%06x' % pil_color
    # reverse byte order
    r, g, b = hexstr[4:], hexstr[2:4], hexstr[:2]
    r, g, b = [int(n, 16) for n in (r, g, b)]
    return (r, g, b)
 convert a PIL-compatible integer into an (r, g, b) tuple 
recipes/Python/266466_HTML_colors_tofrom_RGB_tuples/recipe-266466.py