An external application written in c++ requires me to pass in an image object it would understand i.e. with tostring() method, passing in a encoder and parameters.
How can I get the image and convert it to a string (without saving the image to file)?
image_url is the url to an actual image online i.e http://www.test.com/image1.jpg
This is what I have tried:
def pass_image(image_url):
import base64
str = base64.b64encode(image_url.read())
app = subprocess.Popen("externalApp",
in=subprocess.PIPE,
out=subprocess.PIPE)
app.in.write(str)
app.in.close()
I have also tried to open the image to convert it
image = Image.open(image_url)
but get the error
file() argument 1 must be encoded string without NULL bytes, not str