Sending an image to a REST API is about choosing a convention. Here are some helpers.
from jyquickhelper import add_notebook_menu
add_notebook_menu()
from lightmlrestapi.testing.data import get_wiki_img
imgpath = get_wiki_img()
from IPython.display import Image
Image(imgpath, width=200)
from PIL import Image
img = Image.open(imgpath)
img.size
(456, 415)
from lightmlrestapi.args import image2base64
ext, b64 = image2base64(img)
len(b64), type(b64)
(114676, bytes)
from lightmlrestapi.args import base642image
img2 = base642image(b64)
img2.resize((150,150))
from lightmlrestapi.args import image2array
arr = image2array(img)
arr.shape
(415, 456, 3)