Ejemplo n.º 1
0
def rgba_to_rgb(arr: np.array):

    try:
        w, h = arr.size
        if arr.getdata().mode == 'RGBA':
            arr = arr.convert('RGB')
        nparray = np.array(arr.getdata())
        reshaped = nparray.reshape((w, h, 3))
        reshaped = reshaped.astype(np.uint8)
    except Exception as e:
        print(f"ERROR: {e}")
        raise Exception

    return reshaped