Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
OCR.SetImage
Provide an image for Tesseract to recognize.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
OCR | 2.9 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "OCR.SetImage"; imageRef ) More
Parameters
Parameter | Description | Example |
---|---|---|
imageRef | The image reference. Use functions like GMImage.NewFromContainer 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, WinPDF.PageImage or DynaPDF.RenderPage can help here.
If the PDF file contains real text, please use PDFKit.GetPDFText, PDFKit.GetPDFPageText, DynaPDF.ExtractText, DynaPDF.ExtractPageText or DynaPDF.ExtractPageRectText. This will not do OCR, but extract the text directly.
Optionally you can define area of interest with OCR.SetRectangle function.
Examples
Set image reference:
MBS( "OCR.SetImage"; $img )
Load image, apply effect and pass with rectangle:
Set Variable [ $img ; Value: MBS("GMImage.NewFromContainer"; OCR::Image) ]
// apply some effects here like increase contrast
Set Variable [ $r ; Value: MBS( "OCR.SetImage"; $img) ]
Set Variable [ $r ; Value: MBS( "OCR.SetRectangle"; 0; 0; 1000; 400) ]
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $img) ]
See also
- DynaPDF.ExtractPageText
- DynaPDF.ExtractText
- DynaPDF.RenderPage
- GMImage.NewFromContainer
- OCR.GetText
- OCR.GetTextWithCoordinates
- OCR.SetRectangle
- PDFKit.GetPDFPageImage
- PDFKit.GetPDFPageText
- WinPDF.PageImage
Release notes
- Version 11.3
- Added OCR.SetImageContainer and OCR.SetImageFile functions to directly feed image files (and containers).
Example Databases
Blog Entries
This function is free to use.
Created 18th August 2014, last changed 1st April 2023