Usage ‐ OCR - Attacler/TextToAnything-Directus GitHub Wiki

Using OCR

Interface

When adding a field, choose the OCR interface: image

This enables two features on the page:

Sidebar button

image Click to upload a file from disk for OCR.

Image button

Hover over an image to show the OCR button: image Clicking on a OCR button opens a draggable floating window: image You can drag the window across the screen. Click highlighted text to insert it into any input by simply clicking the input.

Flows

For using OCR inside of flows you can use the following image: image This operation always works based on a Directus FileID.

Programmatically

You can also use OCR within Directus Hooks/Endpoints/Operations. This can be done trough globalThis.TTA.

Based on a file

Example usage:

const result = await globalThis.TTA.OCRBasedOnAsset(
      fileID,
      language, // for example eng for english
      mode // can be text, horc or blocks
);

Based on a buffer

Example usage:

const result = await globalThis.TTA.OCRbasedOnFileBuffer(
      buffer, // the buffer that contains the image
      fileName, // name of the file, for example test.png
      language, // for example eng for english
      mode // can be text, horc or blocks
);