def METHOD_NAME(im: np.ndarray, quality=95, transparent=None) -> bytes:
    if transparent is not None:
        im = replace_transparent_pixels(im, transparent)
    return _compress_image(im, "JPEG", quality=quality)