Skip to content

mismaah/ocr-service

Repository files navigation

OCR Service

Uses gosseract (wrapper for tesseract-ocr) to provide a service which returns text from an image. Input options are image URL and image upload using a multipart-form.

Usage

Pull and start the service

docker run --name ocr-service --restart unless-stopped -p 8123:8123 -e PORT=8123 -e AUTH_KEY=secret123 ghcr.io/mismaah/ocr-service:main

AUTH_KEY is an optional environment variable. If this is set, all API calls should have the Authorization header.

Endpoints

Text from URL

curl --location --request POST 'http://localhost:8123/text/url?url=https://image.png' --header 'Authorization: ••••••'

Text from file upload

curl --location 'http://localhost:8123/text/upload' --header 'Authorization: ••••••' --form 'file=@"file.jpg"'

Response

If successful, returns the text from the image:

{
  "text": "Example text from the image."
}

If error, returns the error message:

{
  "error": "Error reading from image."
}

About

tesseract-ocr as a web API service

Topics

Resources

License

Stars

Watchers

Forks

Packages