import cv2
import numpy as np
import json
import base64, requests
import io, flask
from PIL import Image
everyone requires image as input and some other arguments(as data payload)
Run docker-compose up -d --build (This will build and make the container up and running with localhost endpoint at 5000 port open for rest request)
url = 'http://localhost:5000/rotate'
my_img = {'image': open('./images/satelliite/106.png', 'rb')}
payload = {'angle':"50"}
response = requests.post(url, files=my_img, data=payload)
print(response.text)
# convert server response into JSON format.
im_b64 = response.json()['image']
im_binary = base64.b64decode(im_b64)
buf = io.BytesIO(im_binary)
img = Image.open(buf)
img
url = 'http://127.0.0.1:5000/rotate'
my_img = {'image': open('./images/satelliite/106.png', 'rb')}
payload = {}
response = requests.post(url, files=my_img, data=payload)
print(response.text)
# convert server response into JSON format.
im_b64 = response.json()['image']
im_binary = base64.b64decode(im_b64)
buf = io.BytesIO(im_binary)
img = Image.open(buf)
img
url = 'http://127.0.0.1:5000/resize'
my_img = {'image': open('./images/satelliite/106.png', 'rb')}
payload = {}
response = requests.post(url, files=my_img, data=payload)
# convert server response into JSON format.
im_b64 = response.json()['image']
im_binary = base64.b64decode(im_b64)
buf = io.BytesIO(im_binary)
img = Image.open(buf)
img
url = 'http://127.0.0.1:5000/resize'
my_img = {'image': open('./images/satelliite/106.png', 'rb')}
payload = {"lengthScale":"25", "breadthScale":"25"}
response = requests.post(url, files=my_img, data=payload)
# convert server response into JSON format.
im_b64 = response.json()['image']
im_binary = base64.b64decode(im_b64)
buf = io.BytesIO(im_binary)
img = Image.open(buf)
img
url = 'http://127.0.0.1:5000/crop'
my_img = {'image': open('./images/satelliite/106.png', 'rb')}
payload = {"x":"150","x1":"1500","y":"150", "y1":"1500"}
response = requests.post(url, files=my_img, data=payload)
# convert server response into JSON format.
im_b64 = response.json()['image']
im_binary = base64.b64decode(im_b64)
buf = io.BytesIO(im_binary)
img = Image.open(buf)
img
url = 'http://127.0.0.1:5000/crop'
my_img = {'image': open('./images/satelliite/106.png', 'rb')}
payload = {}
response = requests.post(url, files=my_img, data=payload)
# convert server response into JSON format.
im_b64 = response.json()['image']
im_binary = base64.b64decode(im_b64)
buf = io.BytesIO(im_binary)
img = Image.open(buf)
img