OcrSpace
Simple API wrapper for OCR.Space, A awesome Free api for converting images to text. Register here for free api key.
Installation
Add this line to your application's Gemfile:
gem 'ocr_space'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ocr_space
Hosted at rubygems.org
#ENV Variables (Optional)
setting env variables with api key is optional but for commandline interface to work you will have to set ENV variable 'ocr_api_key' to your apikey. For more details on Command line interface, scroll to the bottom of this page.
$ export ocr_api_key='YOUR API KEY'
Usage
Instantiate OcrSpace resource with apikey
require 'ocr_space'
resource = OcrSpace::Resource.new(apikey: "YOUR API KEY")
#To convert images from url
result = resource.convert url: "http://bit.ly/2ih9aXt"
puts result
=>
result = resource.clean_convert url: "http://bit.ly/2ih9aXt"
puts result
=>
#To convert images from file upload
result = resource.convert file: "/Users/suyesh/Desktop/nicola_tesla.jpg"
puts result
=>
result = resource.clean_convert file: "/Users/suyesh/Desktop/nicola_tesla.jpg"
puts result
=>
#COMMAND LINE INTERFACE BONUS
You can run ocr_space through shell to get quick result from a image using filepath or url
$ ocrspace /Users/suyesh/Desktop/nicola_tesla.jpg
=> If you want to find the secrets of the universe, think in terms of energy, frequency and vibration. AZ QUOTES
#Optional
You can also pass in Optional attributes
isOverlayRequired:
language: