How to Convert Image to Base64 String in Python?
Now, let's see a tutorial of how to convert image to base64 in python. In this article, we will implement a python convert image to base64. We will look at an example of how to convert image to base64 string in python. This example will help you how to decode image to base64 string in python. So, let's follow a few steps to create an example of how to decode image to base64 in python.
If you are looking to convert image to base64 string in python then I will help you with that. I will give you a very simple example, we will take one image "image.png" and then convert it into the base64 string. we will use base64 library. So, without further ado, let's see simple examples: You can use these examples with python3 (Python 3) version.
# Import base64 Module import base64 # Python Convert Image to Base64 String with open("image.png", "rb") as imageFile: encodedString = base64.b64encode(imageFile.read()) print(encodedString);
JVBERi0xLjMNCiXi48/TDQoNCjEgMCBvYmoNCjw8DQovVHlwZSAvQ NCjw8DQovVHlwZSAvQ2F0YWxvZw0KL091dGxpbmVzIDIgM 48/TDQoNCjEgMCBvYmoNCjw8DQovVHlwZSAvQ2F0YWxvZw0KL091dGxpbmV QoNCjEgMCBvYmoNCjw8DQ......
I hope it can help you...
We are Recommending you
- Python Convert base64 String to PNG Image Example
- How to Convert base64 to PDF in Python?
- How to Convert base64 to Image in Python?
- How to Pretty Print JSON in Python?
- Python Dictionary Check if Value is Empty Example
- How to Check if Python Dictionary is Empty or Not?
- Python Read Excel File with Multiple Sheets Example
- How to Convert Image to Base64 in Laravel?
- Python Read and Write a JSON File Example
- Python Post Request with pem File Example
- Python Post Request with Bearer Token Example
- Python Get First Date of Next Month Example
- Python PUT Request with Parameters Example