The Image Properties feature detects general attributes of the image, such as dominant color.
Detecting Image Properties in a Local Image
Protocol
Refer to the images:annotate
API endpoint for complete details.
To perform Image Properties detection, make a POST request and provide the
appropriate request body:
POST https://vision.googleapis.com/v1/images:annotate?key=YOUR_API_KEY
{
"requests": [
{
"image": {
"content": "/9j/7QBEUGhvdG9zaG9...base64-encoded-image-content...fXNWzvDEeYxxxzj/Coa6Bax//Z"
},
"features": [
{
"type": "IMAGE_PROPERTIES"
}
]
}
]
}
See the AnnotateImageRequest
reference documentation for more information on configuring the request body.
If the request is successful, the server returns a 200 OK HTTP status code and
the response in JSON format:
{
"responses": [
{
"imagePropertiesAnnotation": {
"dominantColors": {
"colors": [
{
"color": {
"red": 69,
"green": 42,
"blue": 27
},
"score": 0.15197733,
"pixelFraction": 0.14140345
},
{
"color": {
"red": 159,
"green": 193,
"blue": 252
},
"score": 0.12624279,
"pixelFraction": 0.046971671
},
{
"color": {
"red": 25,
"green": 18,
"blue": 13
},
"score": 0.12161674,
"pixelFraction": 0.15410289
},
{
"color": {
"red": 120,
"green": 168,
"blue": 250
},
"score": 0.06179978,
"pixelFraction": 0.018316509
},
{
"color": {
"red": 61,
"green": 46,
"blue": 28
},
"score": 0.068530552,
"pixelFraction": 0.052263107
},
{
"color": {
"red": 181,
"green": 202,
"blue": 239
},
"score": 0.061842542,
"pixelFraction": 0.030364702
},
{
"color": {
"red": 131,
"green": 168,
"blue": 234
},
"score": 0.054366827,
"pixelFraction": 0.018153695
},
{
"color": {
"red": 122,
"green": 162,
"blue": 249
},
"score": 0.039461233,
"pixelFraction": 0.010827092
},
{
"color": {
"red": 39,
"green": 27,
"blue": 12
},
"score": 0.034653772,
"pixelFraction": 0.02596874
},
{
"color": {
"red": 51,
"green": 24,
"blue": 12
},
"score": 0.033614498,
"pixelFraction": 0.024991859
}
]
}
}
}
]
}
C#
Before trying this sample, follow the C# setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision C# API reference documentation .
Go
Before trying this sample, follow the Go setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision Go API reference documentation .
Java
Before trying this sample, follow the Java setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision Java API reference documentation .
Node.js
Before trying this sample, follow the Node.js setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision Node.js API reference documentation .
PHP
Before trying this sample, follow the PHP setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision PHP API reference documentation .
Python
Before trying this sample, follow the Python setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision Python API reference documentation .
Ruby
Before trying this sample, follow the Ruby setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision Ruby API reference documentation .
Detecting Image Properties in a remote image
For your convenience, the Vision can perform Image Properties detection directly on an image file located in Google Cloud Storage or on the Web without the need to send the contents of the image file in the body of your request.
Protocol
Refer to the images:annotate
API endpoint for complete details.
To perform Image Properties detection, make a POST request and provide the
appropriate request body:
POST https://vision.googleapis.com/v1/images:annotate?key=YOUR_API_KEY
{
"requests": [
{
"image": {
"source": {
"gcsImageUri": "gs://YOUR_BUCKET_NAME/YOUR_FILE_NAME"
}
},
"features": [
{
"type": "IMAGE_PROPERTIES"
}
]
}
]
}
See the AnnotateImageRequest
reference documentation for more information on configuring the request body.
If the request is successful, the server returns a 200 OK HTTP status code and
the response in JSON format:
{
"responses": [
{
"imagePropertiesAnnotation": {
"dominantColors": {
"colors": [
{
"color": {
"red": 69,
"green": 42,
"blue": 27
},
"score": 0.15197733,
"pixelFraction": 0.14140345
},
{
"color": {
"red": 159,
"green": 193,
"blue": 252
},
"score": 0.12624279,
"pixelFraction": 0.046971671
},
{
"color": {
"red": 25,
"green": 18,
"blue": 13
},
"score": 0.12161674,
"pixelFraction": 0.15410289
},
{
"color": {
"red": 120,
"green": 168,
"blue": 250
},
"score": 0.06179978,
"pixelFraction": 0.018316509
},
{
"color": {
"red": 61,
"green": 46,
"blue": 28
},
"score": 0.068530552,
"pixelFraction": 0.052263107
},
{
"color": {
"red": 181,
"green": 202,
"blue": 239
},
"score": 0.061842542,
"pixelFraction": 0.030364702
},
{
"color": {
"red": 131,
"green": 168,
"blue": 234
},
"score": 0.054366827,
"pixelFraction": 0.018153695
},
{
"color": {
"red": 122,
"green": 162,
"blue": 249
},
"score": 0.039461233,
"pixelFraction": 0.010827092
},
{
"color": {
"red": 39,
"green": 27,
"blue": 12
},
"score": 0.034653772,
"pixelFraction": 0.02596874
},
{
"color": {
"red": 51,
"green": 24,
"blue": 12
},
"score": 0.033614498,
"pixelFraction": 0.024991859
}
]
}
}
}
]
}
C#
Before trying this sample, follow the C# setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision C# API reference documentation .
Go
Before trying this sample, follow the Go setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision Go API reference documentation .
Java
Before trying this sample, follow the Java setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision Java API reference documentation .
Node.js
Before trying this sample, follow the Node.js setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision Node.js API reference documentation .
PHP
Before trying this sample, follow the PHP setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision PHP API reference documentation .
Python
Before trying this sample, follow the Python setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision Python API reference documentation .
Ruby
Before trying this sample, follow the Ruby setup instructions in the Vision Quickstart Using Client Libraries . For more information, see the Vision Ruby API reference documentation .

