Image to Text API - Ruby Gem
Image to Text is a simple tool for extracting text from images. It returns the extracted text.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_imagetotext'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_imagetotext
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_imagetotext'
# Initialize the client
client = APIVerve::Imagetotext::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ url: "https://findingtom.com/images/uploads/what-is-medium-com/article-image-15.png" })
# Print the response
puts response
File Upload
# Upload a file
response = client.execute_with_file("/path/to/file.jpg")
# Or use a URL
response = client.execute_with_url("https://example.com/image.jpg")
Error Handling
begin
response = client.execute({ url: "https://findingtom.com/images/uploads/what-is-medium-com/article-image-15.png" })
puts response["data"]
rescue APIVerve::Imagetotext::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Imagetotext::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Imagetotext::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"text": "Ayear after that (in 2021) I hired somebody tpHfelp me write blog posts for\nmy personal website.\n\nThe point is, | like reinvesting the money | make\nback into my business.",
"confidence": 88,
"words": 28,
"characters": 170,
"lines": 5
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://imagetotext.apiverve.com?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.