OCR.SetImage
------------

Provide an image for Tesseract to recognize.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [OCR](component_OCR.md) | [2.9](newinversion29.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "OCR.SetImage"; ImageRef ) 

**MBS**( **"OCR.SetImage";** /\* Provide an image for Tesseract to recognize. \*/  
**$ImageRef**) /\* The image reference. Use functions like [GMImage.NewFromContainer](GMImageNewFromContainer.md) to get an image reference.e.g. $img \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| ImageRef | The image reference. Use functions like [GMImage.NewFromContainer](GMImageNewFromContainer.md) to get an image reference. | $img |

### Result

Returns OK on success.

### Description

Provide an image for Tesseract to recognize.   
The plugin makes a copy of the image.  
  
Please do not pass PDF files. For PDF you either need to extract image (for scans) or raster PDF pages as images. Our functions [PDFKit.GetPDFPageImage](PDFKitGetPDFPageImage.md), [WinPDF.PageImage](WinPDFPageImage.md) or [DynaPDF.RenderPage](DynaPDFRenderPage.md) can help here.  
If the PDF file contains real text, please use [PDFKit.GetPDFText](PDFKitGetPDFText.md), [PDFKit.GetPDFPageText](PDFKitGetPDFPageText.md), [DynaPDF.ExtractText](DynaPDFExtractText.md), [DynaPDF.ExtractPageText](DynaPDFExtractPageText.md) or [DynaPDF.ExtractPageRectText](DynaPDFExtractPageRectText.md). This will not do OCR, but extract the text directly.   
  
Optionally you can define area of interest with [OCR.SetRectangle](OCRSetRectangle.md) function.  
### Examples

Set image reference:

 MBS ( "OCR.SetImage"; $img )  
Load image, apply effect and pass with rectangle:

 Set Variable \[ $img ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; OCR::Image ) \]   
\# apply some effects here like increase contrast   
Set Variable \[ $r ; Value: MBS ( "OCR.SetImage"; $img ) \]   
Set Variable \[ $r ; Value: MBS ( "[OCR.SetRectangle](OCRSetRectangle.md)"; 0; 0; 1000; 400) \]   
Set Variable \[ $r ; Value: MBS ( "[GMImage.Release](GMImageRelease.md)"; $img ) \]  
### See also

- [DynaPDF.ExtractText](DynaPDFExtractText.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [OCR.GetTextWithCoordinates](OCRGetTextWithCoordinates.md)
- [OCR.RenderPDF](OCRRenderPDF.md)
- [OCR.SetImageContainer](OCRSetImageContainer.md)
- [OCR.SetImageFile](OCRSetImageFile.md)
- [OCR.SetRectangle](OCRSetRectangle.md)
- [PDFKit.GetPDFPageText](PDFKitGetPDFPageText.md)
- [PDFKit.GetPDFText](PDFKitGetPDFText.md)
- [WinPDF.PageImage](WinPDFPageImage.md)

### Release notes

- **Version 11.3**
    - Added [OCR.SetImageContainer](https://www.mbsplugins.eu/OCRSetImageContainer.shtml) and [OCR.SetImageFile](https://www.mbsplugins.eu/OCRSetImageFile.shtml) functions to directly feed image files (and containers).

### Example Databases

- [OCR/OCR with DynaPDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/OCR/OCR%20with%20DynaPDF.shtml#1ScriptAnchor_)
- [OCR/OCR](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/OCR/OCR.shtml#1ScriptAnchor_)

### Blog Entries

- [Live barcode reading for FileMaker on MacOS and iOS](https://www.mbsplugins.de/archive/2018-08-30/Live_barcode_reading_for_FileM/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 3.0pr5](https://www.mbsplugins.de/archive/2012-10-26/MBS_Filemaker_Plugin_version_3/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 18th August 2014 , last changed 25th February 2026

  
[OCR.RenderPDF](OCRRenderPDF.md) - [OCR.SetImageContainer](OCRSetImageContainer.md)

[HTML Version](OCRSetImage.shtml)