storage-extract-image-text/extension.yaml (137 lines of code) (raw):
name: storage-extract-image-text
version: 0.1.6
specVersion: v1beta
displayName: Extract Image Text with Cloud Vision AI
description:
Extracts text from images and saves to Firestore using Cloud Vision API.
license: Apache-2.0 # The license you want for the extension
icon: icon.png
tags:
[
ai,
image,
text-extraction,
cloud-vision,
image-recognition,
image-classification,
text-recognition,
character-recognition,
ocr,
google-ai,
cloud-vision-api,
]
author:
authorName: Google Cloud
url: https://cloud.google.com
contributors:
- authorName: Invertase
email: oss@invertase.io
url: https://github.com/invertase
sourceUrl: https://github.com/GoogleCloudPlatform/firebase-extensions/tree/main/storage-extract-image-text
releaseNotesUrl: https://github.com/GoogleCloudPlatform/firebase-extensions/tree/main/storage-extract-image-text/CHANGELOG.md
billingRequired: true
apis:
- apiName: vision.googleapis.com
reason: Powers all Vision tasks performed by the extension.
resources:
- name: extractText
type: firebaseextensions.v1beta.function
description:
Listens to incoming Storage documents, executes OCR on them and writes
extracted text to Firestore into a preconfigured collection.
properties:
location: ${param:LOCATION}
availableMemoryMb: 1024
eventTrigger:
eventType: google.storage.object.finalize
resource: projects/_/buckets/${param:IMG_BUCKET}
runtime: nodejs20
params:
- param: LOCATION
label: Cloud Functions location
description: >-
Where do you want to deploy the functions created for this extension? You
usually want a location close to your database. Realtime Database
instances are located in `us-central1`. For help selecting a location,
refer to the [location selection
guide](https://firebase.google.com/docs/functions/locations).
type: select
options:
- label: Iowa (us-central1)
value: us-central1
- label: South Carolina (us-east1)
value: us-east1
- label: Northern Virginia (us-east4)
value: us-east4
- label: Belgium (europe-west1)
value: europe-west1
- label: London (europe-west2)
value: europe-west2
- label: Frankfurt (europe-west3)
value: europe-west3
- label: Hong Kong (asia-east2)
value: asia-east2
- label: Tokyo (asia-northeast1)
value: asia-northeast1
default: us-central1
required: true
immutable: true
- param: IMG_BUCKET
label: Cloud Storage bucket for images
description: >
To which Cloud Storage bucket will you upload images from which you want
to extract text?
type: string
example: my-project-12345.appspot.com
validationRegex: ^([0-9a-z_.-]*)$
validationErrorMessage: Invalid storage bucket
default: ${STORAGE_BUCKET}
required: true
- param: COLLECTION_PATH
label: Collection path
description: >
What is the path to the collection where extracted text will be written
to.
example: extractedText
validationRegex: '^[^/]+(/[^/]+/[^/]+)*$'
validationErrorMessage: Must be a valid Cloud Firestore Collection
default: extractedText
required: true
- param: INCLUDE_PATH_LIST
label: Paths that contain images you want to extract text from
description: >
Restrict storage-image-text-extraction to only extract text from images in
specific locations in your Storage bucket by supplying a comma-separated
list of absolute paths. For example, specifying the paths
`/users/pictures,/restaurants/menuItems` will process any images found in
any subdirectories of `/users/pictures` and `/restaurants/menuItems`.
If you prefer not to explicitly exclude any directories of your Storage
bucket, leave this field empty.
type: string
example: '/users/avatars,/design/pictures'
validationRegex: ^(\/[^\s\/\,]+)+(\,(\/[^\s\/\,]+)+)*$
validationErrorMessage:
Invalid paths, must be a comma-separated list of absolute path values.
required: false
- param: EXCLUDE_PATH_LIST
label: List of absolute paths not included for image text extraction
description: >
Ensure storage-image-text-extraction does *not* process images in
_specific locations_ in your Storage bucket by supplying a
comma-separated list of absolute paths. For example, to *exclude* the
images stored in the `/foo/alpha` and its subdirectories and `/bar/beta`
and its subdirectories, specify the paths `/foo/alpha,/bar/beta`.
If you prefer to process every image uploaded to your Storage bucket,
leave this field empty.
type: string
example: '/users/avatars/thumbs,/design/pictures/thumbs'
validationRegex: ^(\/[^\s\/\,]+)+(\,(\/[^\s\/\,]+)+)*$
validationErrorMessage:
Invalid paths, must be a comma-separated list of absolute path values.
required: false
- param: DETAIL
label: Amount of text extraction information to write to firestore.
description: >
How much information should be written to firestore? Do you want just the
extracted text written to firestore, or the full data of the annotation?
Select \"basic\" for the former, \"full\" for the later.
type: select
options:
- label: Basic
value: basic
- label: Full
value: full
default: basic
required: true
roles:
- role: storage.objectAdmin
reason: Allows the extension to write to your Cloud Storage.
- role: datastore.user
reason: Allows the extension to write to your Firestore Database instance.