diff --git a/src/AI.md b/src/AI.md index a6d5a10..d77e773 100644 --- a/src/AI.md +++ b/src/AI.md @@ -63,7 +63,7 @@ You can use AI models from various providers to perform tasks such as chat, text diff --git a/src/AI/img2txt.md b/src/AI/img2txt.md index cef3a7a..7ba784f 100755 --- a/src/AI/img2txt.md +++ b/src/AI/img2txt.md @@ -4,24 +4,40 @@ description: Extract text from images using OCR to read printed text, handwritin platforms: [websites, apps, nodejs, workers] --- -Given an image will return the text contained in the image. Also known as OCR (Optical Character Recognition), this API can be used to extract text from images of printed text, handwriting, or any other text-based content. +Given an image will return the text contained in the image. Also known as OCR (Optical Character Recognition), this API can be used to extract text from images of printed text, handwriting, or any other text-based content. You can choose between AWS Textract (default) or Mistral’s OCR service when you need multilingual or richer annotation output. ## Syntax ```js puter.ai.img2txt(image, testMode = false) +puter.ai.img2txt(image, options = {}) +puter.ai.img2txt({ source: image, ...options }) ``` ## Parameters -#### `image` (String|File|Blob) (required) +#### `image` / `source` (String|File|Blob) (required) -A string containing the URL, or path (on Puter) of the image you want to recognize, or a `File` or `Blob` object containing the image. +A string containing the URL or Puter path of the image you want to recognize, or a `File`/`Blob` object containing the image. When calling with an options object, pass it as `{ source: ... }`. #### `testMode` (Boolean) (Optional) A boolean indicating whether you want to use the test API. Defaults to `false`. This is useful for testing your code without using up API credits. +#### `options` (Object) (Optional) + +An options object with the following properties: + +- `provider` (String) (Optional) - Choose the OCR backend. Can be `aws-textract` or `mistral`. Defaults to `aws-textract`. +- `model` (String) (Optional) - Mistral OCR model to use. Defaults to `mistral-ocr-latest`. +- `pages` (Array) (Optional) - Limit processing to specific page numbers (multi-page PDFs). +- `includeImageBase64` (Boolean) (Optional) - Mistral-only: requests the base64 of cropped regions in the response. +- `imageLimit` (Number) (Optional) - Control how many images are analyzed per document (Mistral). +- `imageMinSize` (Number) (Optional) - Set minimum size for images to be analyzed (Mistral). +- `bboxAnnotationFormat` (String) (Optional) - Mistral: format for bounding-box annotations (e.g., `yolo`, `xyxy`). +- `documentAnnotationFormat` (String) (Optional) - Mistral: request document-level annotations/markdown variants. +- `testMode` (Boolean) (Optional) - Same as positional argument; also works inside the options object. + ## Return value A `Promise` that will resolve to a string containing the text contained in the image. @@ -37,8 +53,8 @@ In case of an error, the `Promise` will reject with an error message. -``` +``` \ No newline at end of file diff --git a/src/assets/css/style.css b/src/assets/css/style.css index e142d64..916131c 100755 --- a/src/assets/css/style.css +++ b/src/assets/css/style.css @@ -200,6 +200,42 @@ ul code { /* So our .anchor can be positioned absolutely */ } +.docs-content table { + width: 100%; + border-collapse: collapse; + margin: 24px 0; + font-size: 14px; +} + +.docs-content table thead, .docs-content table tr:first-child { + background: #f5f6fb; +} + +.docs-content table th, +.docs-content table td { + padding: 10px 14px; + border: 1px solid #e2e4ef; + text-align: left; +} + +.docs-content table tbody tr:nth-child(even) { + background: #fbfbfe; +} + +.dark-mode .docs-content table thead, +.dark-mode .docs-content table tr:first-child { + background: rgba(255,255,255,0.05); +} + +.dark-mode .docs-content table tbody tr:nth-child(even) { + background: rgba(255,255,255,0.03); +} + +.dark-mode .docs-content table th, +.dark-mode .docs-content table td { + border-color: rgba(255,255,255,0.08); +} + .anchored-heading:target { background-color: #ffffbe; } @@ -1559,4 +1595,3 @@ footer .copyright-notice{ .platform-name { font-weight: 500; } - diff --git a/src/playground/examples/ai-img2txt.html b/src/playground/examples/ai-img2txt.html index de4f021..8273ce9 100755 --- a/src/playground/examples/ai-img2txt.html +++ b/src/playground/examples/ai-img2txt.html @@ -6,7 +6,7 @@ puter.print(`Loading...`); // Extract text from an image - puter.ai.img2txt('https://cdn.handwrytten.com/www/2020/02/home-hero-photo2%402x.png').then(puter.print); + puter.ai.img2txt('https://assets.puter.site/letter.png').then(puter.print); \ No newline at end of file