"Conveniently convert png, jpg, webp and gif to base64 string - Encode and also, convert your base64 string in any format to Image - Decode"
- File formats accepted include jpeg, png, gif, and webp
- Encoding of all file formats listed above
- Decoding of Base64 string with contents that possess the above four formats
- Downloading of Base64 string compiled in a text format
- Downloading of converted image file is enabled
- Active quick preview of uploads in real time
- Tracking of the user's browser for experimental purposes
- Full View of encoded image
- Contact Tab
- Update Tab
- Encode Image from any direct image link (Advance)
- Integreted Application Programming Interface (API)
new
https://image2base64.herokuapp.com/api/doc/
A Web API for encoding image to Base64 string and decoding any base64 string back to image.
https://image2base64.herokuapp.com/api/doc/
- Click on the api endpoint [POST] /v1/rest-auth/registration/
- Click on the "Try it Out" button
- Enter your details
- Click on the "Execute" button
- Then copy & paste the generated key into the endpoint [POST] /v1/rest-auth/registration/verify-email/
- Ignore the csrf_token error (It is an expected error)
- Go to the top and click the "Login" button';
First install requests library
pip install requests
Then, run the following lines of code:
import requests
context = {"username": "userabc", "email": "userabc@gmail.com", "password": "userabc12345" }
r = requests.post('https://image2base64.herokuapp.com/api/v1/rest-auth/login/', data = context)
print(r.text)
url = {"url": "https://image2base64.herokuapp.com/media/photo-1511469054436-c7dedf24c66b.jpg"}
encode_link = requests.post("https://image2base64.herokuapp.com/api/v1/link/encode/", data = url, headers={ 'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTgyNzI2Nzk0LCJqdGkiOiI1YzBiNjY5ODIxNWY0ZjNiYmU4ODhjOWZlMzBjMjYxNCIsInVzZXJfaWQiOjN9.84hv-O12BvcIjOyESelPT9-ReoAna3w4505BWu9HHrc' })
print(r)
print(r.text)
print(encode_link)
output_dict = encode_link.json()
print(output_dict["image_info"])
Use the link below for the corresponding HTML for the javascript snippet
https://github.com/PiusLucky/ImageBase64/blob/master/ConsumeAPI%20Test/APP/javascript/index.html
$.ajax({
method: "POST",
url: 'https://image2base64.herokuapp.com/api/v1/rest-auth/login/', //the url to call
data: {
"username": "userabc12345",
"email": "userabc12345@gmail.com",
"password": "userabc12345"
},
headers: {
"Accept": "application/json",
},
dataType: "json",
success: function (x) {
const login_key = document.querySelector("#login_key")
login_key.append(x["key"])
}
});
// NB: valid link must include "www"
var link = 'https://www.sample-videos.com/img/Sample-jpg-image-50kb.jpg'
$.ajax({
method: "POST",
url: 'https://image2base64.herokuapp.com/api/v1/link/encode/', //the url to call
data: JSON.stringify({
"url": link,
"username": "userabc12345",
"email": "userabc12345@gmail.com",
"password": "userabc12345"
}),
headers: {
"Accept": "application/json",
"Content-Type":"application/json",
},
contentType: "application/json",
dataType: "json",
success: function (response) {
const encode_info = document.querySelector("#encode_info")
const encode_id = document.querySelector("#encode_id")
const image_size = document.querySelector("#image_size")
const image_extension = document.querySelector("#image_extension")
const image_name = document.querySelector("#image_name")
const image_dimension = document.querySelector("#image_dimension")
encode_id.append(response["encode_id"])
image_size.append(response["image_info"]["image_size"])
image_extension.append(response["image_info"]["image_extension"])
image_name.append(response["image_info"]["image_name"])
image_dimension.append(response["image_info"]["image_dimension"])
encode_info.append(response["raw_copy_base64"])
},
error: function(response){
const encode_info = document.querySelector("#encode_info")
result = JSON.stringify(response)
encode_info.append(result)
}
});
What is Base64?
It is worthy of note that some tools used in rendering HTML into PDF requires an image file first be converted to Base64 before it can be rendered.
Is base64 URL safe?
Can the encoded Base64 string be compiled in a text file?
why is 1.00 MB the maximum allowed for file upload?
Are uploaded files saved permanently?
The explanations go thus:
- The image is uploaded to a specific folder depending on process.
- The image data is read and encoded to a base64 string.
- The image metadata, like size and mimetype, is read.
- The image is then deleted.
Take a look at the background processess:
How can I save the decoded Base64 string (i.e result)?
Made with β€ by Pius Lucky