API Reference

This page describes image encoding procedure

Base64 is an encoding procedure that results in a text format of binary input data. You can learn more on Base64 here. Our goal is to ensure that the image is properly encoded prior to sending it on our extraction service. This might help you along the way.

Below are some examples how to perform image encoding::

import base64


img_path = "..."
with open(img_path, 'rb') as file:
    encoded = base64.b64encode(file.read()).decode('ascii')

print(encoded)
export const imgToBase64 = (file) =>
    
	new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => resolve(reader.result.slice(reader.result.indexOf(',') + 1));
    reader.onerror = (error) => reject(error);
  });

The operation must discard encoding header such as following:

data:image/png;base64,...