Introducing the OCR Robot for easy text extraction
"A picture is worth a thousand words" is an adage in many languages – and for good reason. Our visual cortex is arguably the most powerful part of the brain, and leveraging that to convey meaning is equally powerful. With the introduction of our /image/describe Robot, we allow programmers to unlock the visual cortex of AI models trained by prominent cloud vendors. Today, we are taking this a step further by not only recognizing objects in images, but also reading any words present.
Let's say you had a picture of a traffic sign, or a menu. Almost any human would be able to make sense of these objects, but their meaning has always been opaque to machines until the introduction of powerful new OCR models that can read – virtually – text from a collection of pixels.
Introducing the /image/ocr Robot. The newest member of
our AI Robot family. It can use either AWS or GCP in the backend, with each provider
being easily swappable using the provider parameter. This means that if one provider produces
unfavorable results, you can try the other through the same Robot interface. Recognition results
can differ between providers and change as their models evolve, so test with representative images
rather than relying on an exact response.

Extracting text from images
To demonstrate how simple it is to use this new Robot, we will walk through the Template below:
{
"steps": {
":original": {
"robot": "/upload/handle"
},
"image-ocr": {
"use": ":original",
"robot": "/image/ocr",
"format": "text",
"provider": "aws"
},
"exported": {
"use": ["image-ocr", ":original"],
"robot": "/s3/store",
"credentials": "YOUR_AWS_CREDENTIALS",
"acl": "bucket-default",
"path": "ocr/${unique_prefix}/${file.url_name}"
}
}
}
There are many options for getting files to Transloadit, but we will be
using the /upload/handle Robot in our first
Step, :original.
Our image recognition occurs in the following Step, image-ocr. Here, we pass
:original to our /image/ocr Robot and specify its
format parameter to return its result as a text file. If you omit format, the Robot
outputs JSON. Additionally, we have specified that we want to use aws as the
backend AI provider. Writing gcp here selects Google Cloud instead. The text format still
produces a text file, but its recognized words, grouping and ordering can differ.
After extraction, we export both the text file and the original image to your S3 bucket.
Replace YOUR_AWS_CREDENTIALS with the name of your saved Template Credentials.
Follow the shared Credential creation procedure
and the S3 setup guide to configure your own bucket
and scoped access. The example omits an object ACL by using bucket-default; keep Block Public
Access enabled and do not add a bucket policy that grants public read. The unique path avoids
overwriting another upload with the same filename.
Testing
Now, let's test our Template with the image below:
The Robot converts image formats such as this SVG to a provider-compatible raster image before recognition. For this logo, a text result can look like the following; recognition is not guaranteed to reproduce the same spelling or capitalization on every run:
Transloadit
Conclusion
In this short introduction, we have shown how to add text extraction to a workflow using our /image/ocr Robot.
What's more, thanks to Transloadit's composability, all of our 96 Robots can be strung together to create workflows unique to your use case. In other words, the OCR Step could be just one of the many cogs that make up your intricate machine. As shown, it only takes a declaratively written JSON recipe to set this up. Validate the results against your application's needs, especially before making decisions based on recognized text.
See our pricing page for AI feature availability, included usage and current processing charges.
