doc-exports/docs/ocr/umn/ocr_01_0032.html
Sheng, Lichang 86871abfe4 OCR usermanual 20240111 v2
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Sheng, Lichang <lichangsheng1@noreply.gitea.eco.tsi-dev.otc-service.com>
Co-committed-by: Sheng, Lichang <lichangsheng1@noreply.gitea.eco.tsi-dev.otc-service.com>
2024-01-17 10:42:31 +00:00

935 B

How Can I Get the Base64 Encoding of an Image?

To recognize an image, it must first be converted to its Base64 coding. This section provides an example using Python to explain how to convert a local image to Base64 code. You can also use an online conversion tool.

Replace d:\demo.jpg in the code with the actual image path.

import base64 
with open("d:\demo.jpg", "rb") as image_file: 
    encoded_string = base64.b64encode(image_file.read()).decode() 
print(encoded_string)