OCR API gets Base64 Support

New: Send images as Base64-string

The November Free OCR API update adds two often requested features:

  • Easier authentication via request header

  • Base 64 support for sending images

The API url and format has not changed. Also, we still support the old authentication methods. So, unless you decide to make use of the new features, this upgrade will be 100% transparent to you.

In more details:

New Authentication

The api-key is now submitted via the header. Here is how it looks in Postman:

And here is a cURL example:

curl -H "apikey:helloworld" --form "file=@big.png" --form "language=eng" - -form "isOverlayRequired=true" https://api.ocr.space/parse/image

We continue to support the old authentication method for the time being, so existing applications will not break.

Submit images as Base64

The new parameter is called “base64Image”. In Postman the request looks like this:

What is Base64? As example, we use a simple and small image:

In Base64 format this image is a long string that starts with data:image/png;base64,iVBORw0......

You can use any Image to Base64 converter to create these strings, for example this one.

The cURL command line with the full Base64 string looks as follows:

curl  -H "apikey:helloworld"   --form "base64Image=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAAWCAYAAACYPi8fAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4AofExM4z9cKbwAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAAC5klEQVRYhe2YPZKbQBCFv3X5GIyuQIom2jkAochMTqbCmYkVilJk8g1HmTkA2aDQXEHDPXAAQiCBtK6yasu7+6oUaP66X/frnpGemqZp+ID48tYOvBU+iX80fBI/IU8USimSfH5TlYUoFZJVj3Std+ghtqYzLgQ2nTFWZWy1/bdevAFmpC4QwlKaa+a51ggpH+zW4zFD3MFbCmxpGFPPORiJ503tyUlUWybtJ2FYLVUWosKMPAsHayZUlSfj+fraUjU6Y2yrnRvbhoosVKhB/c42t4VcImzJKOn5ASM9/GtPCFWKkTFFUVAUBbE0pJcOWE1ar7o1OwJh0dvsHNw8QaUGGbdnFLslpTZXpNdaEHd22nMMadie48olAsNhFHVDaUF6Z8/nu7orWV7IPT+Y0eZ+XGusCNhtznP+JkZi2I9SKon7NS7RSkIf3Ipsb0DGnJdEfA/EkAGmtIggGATfRS4F2Jpj7zeYAfPKlFgkQ9dvXGcujuAs9ypjb8abT87UFhAO7mjcx5OMy0U4LGbtHakvsgLgOkPiLtFLwUvk0stXKdajZtsFwhw6tbXB4kKpN+9x35N9JCtTYqdk3nOap/QqVDWTd8XCYZTzvr7XaCuJi4LdSBXgRivkSe4TMod7Dxjf6w5oozYl8xNsfZyeuFLCDNwxwR7HYUBytLaIYNfV92YmEa3azCGflDncfbktcASY/ZbSTskcTiWBrSdugL9RQmfrcNGPazv8gkWwlMNQdlK+gN8yR9fXMoe7xE+Nw96UuR8ECKtZD66LPEkxSFbRq/JN3+xMen41Xj6WXAeBRetB48q2tEss9TDynVqNuZY5wNe77sglQlvEDZnjRrwUDolKUSptx0TAroheJ/Pe2Q0FCSpVtMcIgkBie/I+m11NuL6wEwvWqaE+wtmgjydTzGRDBpp3i9/Nz2/PzfOPX5Oz7/fXWWUorSAIppV6V+r/H3ISlWIAGRfMtZinpvn8z+1D4Q9Qn1zF/oPQJwAAAABJRU5ErkJggg=="  https://api.ocr.space/parse/image 

When you copy the command, make sure you do not insert line breaks by mistake.

Base64 has one small drawback and that is the image size. As a rule of thumb, images send via Base64 are 30% larger than their directly uploaded counterpart. Or in others words, each of the three supported image upload methods (URL, direct upload and Base64) has its own distinct advantage, depending on your use case.