def METHOD_NAME(self):
    try:
        image = self.image.resize(
            (self.width, self.height), Image.ANTIALIAS).convert("L")
    except Exception as e:
        sys.exc_clear()
        print("average_hash error:", e)
        return int(0)
    pixels = list(image.getdata())
    avg = sum(pixels) / len(pixels)
    def compare_value_to_avg(i):
        return (1 if i > avg else 0)
    bitlist = list(map(compare_value_to_avg, pixels))
    # build up an int value from the bit list, one bit at a time
    def set_bit(x, idx_val):
        (idx, val) = idx_val
        return (x | (val << idx))
    result = reduce(set_bit, enumerate(bitlist), 0)
    # print("{0:016x}".format(result))
    return result