MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / detectPropertiesGCS

Function detectPropertiesGCS

vision/detect.js:314–335  ·  view source on GitHub ↗
(bucketName, fileName)

Source from the content-addressed store, hash-verified

312}
313
314async 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
337async function detectSafeSearch(fileName) {
338 // [START vision_safe_search_detection]

Callers 1

detect.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected