added comment
This commit is contained in:
@ -1,4 +1,41 @@
|
||||
#!/bin/bash
|
||||
# -----------------------------------------------------------------------------
|
||||
# WCX Thumbnail OCR
|
||||
#
|
||||
# Extracts text from a local image file or an image URL using the Google Cloud
|
||||
# Vision API.
|
||||
#
|
||||
# The script:
|
||||
# 1. Accepts either a local image path or an HTTP/HTTPS image URL.
|
||||
# 2. Reads or downloads the image and encodes it as Base64.
|
||||
# 3. Sends the image to Google Cloud Vision using TEXT_DETECTION.
|
||||
# 4. Extracts the first detected text annotation from the API response.
|
||||
# 5. Writes the OCR text to standard output or to a file specified with -o.
|
||||
#
|
||||
# Requirements:
|
||||
# - GOOGLE_VISION_API_KEY must be set in the environment.
|
||||
# - curl is required for HTTP requests and remote image downloads.
|
||||
# - base64 is required for encoding the image.
|
||||
# - jq is recommended and is required for clean plain-text output.
|
||||
#
|
||||
# Usage:
|
||||
# ocr.sh <image-file-or-url> [-o output-file]
|
||||
#
|
||||
# Examples:
|
||||
# ./ocr.sh thumbnail.jpg
|
||||
# ./ocr.sh "https://example.com/thumbnail.jpg"
|
||||
# ./ocr.sh "https://example.com/thumbnail.jpg" -o ocr-result.txt
|
||||
#
|
||||
# Output contract:
|
||||
# - Without -o, the detected OCR text is written to standard output.
|
||||
# - With -o, the OCR text is written to the specified file and a completion
|
||||
# message is written to standard output.
|
||||
# - A non-zero exit status indicates invalid input, missing configuration,
|
||||
# missing dependencies, an API failure, or that no text was detected.
|
||||
#
|
||||
# The output is raw OCR text. Its structure is not guaranteed by Google Vision
|
||||
# and must be parsed and validated separately before being stored as metadata.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# --- KONFIGURATION ---
|
||||
# Skriptet förväntar sig nu miljövariabeln: GOOGLE_VISION_API_KEY
|
||||
|
||||
Reference in New Issue
Block a user