Image Recognition Error

Hi! So, in my automation, I realized I needed to separate the PDF files from the IMAGE files (JPEG/PNG) sent. I managed to get it working with PDFs, but I’m having problems with the images.

In the “IF” node, I can do the separation, but when it comes time for the HTTP request to extract the image information and transform it into JSON, an error occurs; it seems it’s not recognizing it. I’ve already sent the code several times to different AI systems to see if they could solve it, but so far nothing has worked.

NOTE: The OCR I’m using is Google Vision.

Can anyone help?

1 Like

Hi @Companny Welcome to the community!
You can do that by converting your image to base64 like extract from file and then move file to base64 string, and just call that google vision using the HTTP node with it’s content type JSON something like this:

{
“requests”: [
{
“image”: { “content”: “{{ $json.data }}” },
“features”: [{ “type”: “TEXT_DETECTION” }]
}
]
}

so that the OCR would receive the valid JSON, does this work?

Hi @Companny welcome to the community!

You can convert the file into base64 string using this node

Then, use that base64 string as an input to the Google Vision API.

The base64 approach mentioned above is the right call, just make sure the base64 string you’re passing doesn’t have the data:image/png;base64, prefix on it because Google Vision will choke on that. If the Extract from File node gives you trouble you can also grab it with a Code node like $input.first().binary.data.data which gives you the raw base64 string directly, then just drop that into your HTTP Request body JSON under image.content.