def METHOD_NAME(self) -> int:
    """
    Pure python version of Perceptual Hash computation of https://github.com/JohannesBuchner/imagehash/tree/master
    Implementation follows http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html
    """
    def generate_dct2(block, axis=0):
        def dct1(block):
            """Perform 1D Discrete Cosine Transform (DCT) on a given block."""
            N = len(block)
            dct_block = [0.0] * N
            for k in range(N):
                sum_val = 0.0
                for n in range(N):
                    cos_val = math.cos(math.pi * k * (2 * n + 1) / (2 * N))
                    sum_val += block[n] * cos_val
                dct_block[k] = sum_val
            return dct_block
        """Perform 2D Discrete Cosine Transform (DCT) on a given block along the specified axis."""
        rows = len(block)
        cols = len(block[0])
        dct_block = [[0.0] * cols for _ in range(rows)]
        if axis == 0:
            # Apply 1D DCT on each row
            for i in range(rows):
                dct_block[i] = dct1(block[i])
        elif axis == 1:
            # Apply 1D DCT on each column
            for j in range(cols):
                column = [block[i][j] for i in range(rows)]
                dct_column = dct1(column)
                for i in range(rows):
                    dct_block[i][j] = dct_column[i]
        else:
            raise ValueError("Invalid axis value. Must be either 0 or 1.")
        return dct_block
    def convert_image_to_ndarray(image):
        width, height = image.size
        pixels2 = []
        for y in range(height):
            row = []
            for x in range(width):
                pixel = image.getpixel((x, y))
                row.append(pixel)
            pixels2.append(row)
        return pixels2
    highfreq_factor = 4
    img_size = 8 * highfreq_factor
    try:
        image = self.image.convert("L").resize((img_size, img_size), Image.Resampling.LANCZOS)
    except Exception:
        logger.exception("p_hash error converting to greyscale and resizing")
        return 0
    pixels = convert_image_to_ndarray(image)
    dct = generate_dct2(generate_dct2(pixels, axis=0), axis=1)
    dctlowfreq = [row[:8] for row in dct[:8]]
    med = median([item for sublist in dctlowfreq for item in sublist])
    # Convert to a bit string
    diff = "".join(str(int(item > med)) for row in dctlowfreq for item in row)
    result = int(diff, 2)
    return result