How to read bytes from a image url (jpeg) and encode in base64 on Python 2.7?

Viewed 6684

I am using the following code:

import urllib, cStringIO
from PIL import Image  
url='https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png'
file = cStringIO.StringIO(urllib.urlopen(url).read())
img = Image.open(file)

based on: How do I read image data from a URL in Python?

Now I need to base64 encode it for posting to Google Cloud Vision API. How to do that?

Or does the Google Cloud vision API work with image urls?

1 Answers
Related