pip install -U image_to_base_64Takes numpy.array or PIL.Image as input
base64 = rgb2base64(rgb_image, image_format)where image format is JPEG, PNG
base64 = grayscale2base64(grayscale_image)output_type = "cv2" # or "PIL"
rgb_image = base64_to_rgb(base64, output_type)output_type = "cv2" # or "PIL"
grayscale_image = base64_to_grayscale(base64, output_type)For some reason I cannot convert RGB image to JPEG representation in base 64 and back without losses.
=> test only for PNG and not JPEG