Skip to content

Instantly share code, notes, and snippets.

@nbortolotti
Created September 23, 2016 17:44
Show Gist options
  • Save nbortolotti/3215f5d1b1f0ba9c3f2abfe98f1df8cb to your computer and use it in GitHub Desktop.
Save nbortolotti/3215f5d1b1f0ba9c3f2abfe98f1df8cb to your computer and use it in GitHub Desktop.
#open a img-file
with open(photo_file, 'rb') as image:
image_content = base64.b64encode(image.read())
service_request = service.images().annotate(
body={
'requests': [{
'image': {
'content': image_content
},
'features': [{
'type': 'IMAGE_PROPERTIES', #type of detection
'maxResults': 1,
}]
}]
})
response = service_request.execute() #service request
color = response['responses'][0]['imagePropertiesAnnotation']['dominantColors']['colors'][0] #information of the response
print('Color: %s para %s' % (color, photo_file)) #print the info
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment