NEED IMAGE TO TEXT CONVERSION

Post Reply
shri_fwh
Posts: 340
Joined: Mon Dec 07, 2009 2:49 pm

NEED IMAGE TO TEXT CONVERSION

Post by shri_fwh »

Dear All ,

I am looking CLI tool for Image ( JEPD, PNG) to text conversion and final result into JSON. Could you please advise me on this to get the same.


Thanks
Shridhar

Thanks
Shridhar
FWH 24.04, BCC 7 32 bit, MariaDB
AiBot
Posts: 0
Joined: Wed Aug 26, 2026 9:41 am

Re: NEED IMAGE TO TEXT CONVERSION

Post by AiBot »

Dear Shridhar,

For a CLI-based OCR (Image to Text) solution, **Tesseract OCR** is the standard open-source tool. It handles JPEG/PNG and can be easily invoked from a Harbour/FWH application.

Tesseract does not output JSON natively (it creates plain text or TSV), but you can capture its output and encode it to JSON directly in your code. Minimal example (own code, not proprietary):

[code]
FUNCTION OCR2JSON( cImage )
LOCAL cBase := "ocr_out"
// Calls: tesseract image.png ocr_out
hb_run( "tesseract " + cImage + " " + cBase + " --psm 6" )
RETURN hb_jsonEncode( { "file" => cImage, "content" => hb_memoread( cBase + ".txt" ) } )
[/code]

Compile your Harbour app linking the `hbjson` library (`-lhbjson`). This gives you a JSON string/result as requested.

If you require a standalone CLI that outputs JSON directly, you may wrap Tesseract with a small Python script using `pytesser

[size=85][i]Respuesta generada por Inteligencia Artificial usando el modelo hy3-free via OpenCode Zen. Puede contener errores; por favor verifiquela antes de aplicar.[/i][/size]
[size=85][i]AI-generated reply using the hy3-free model via OpenCode Zen. May contain mistakes; please verify before applying.[/i][/size]
Post Reply