| 312 | } |
| 313 | |
| 314 | async function detectPropertiesGCS(bucketName, fileName) { |
| 315 | // [START vision_image_property_detection_gcs] |
| 316 | // Imports the Google Cloud client libraries |
| 317 | const vision = require('@google-cloud/vision'); |
| 318 | |
| 319 | // Creates a client |
| 320 | const client = new vision.ImageAnnotatorClient(); |
| 321 | |
| 322 | /** |
| 323 | * TODO(developer): Uncomment the following lines before running the sample. |
| 324 | */ |
| 325 | // const bucketName = 'Bucket where the file resides, e.g. my-bucket'; |
| 326 | // const fileName = 'Path to file within bucket, e.g. path/to/image.png'; |
| 327 | |
| 328 | // Performs property detection on the gcs file |
| 329 | const [result] = await client.imageProperties( |
| 330 | `gs://${bucketName}/${fileName}` |
| 331 | ); |
| 332 | const colors = result.imagePropertiesAnnotation.dominantColors.colors; |
| 333 | colors.forEach(color => console.log(color)); |
| 334 | // [END vision_image_property_detection_gcs] |
| 335 | } |
| 336 | |
| 337 | async function detectSafeSearch(fileName) { |
| 338 | // [START vision_safe_search_detection] |