Answers for "image url to base64 url"

2

img src data base64

<img src="data:image/png;base64,..." /> <!-- Replace png with the mime type of the image --!>
Posted by: Guest on March-01-2021
1

imagen de url a base64

toDataURL('/images/Negativo_Leve.svg', function(dataUrl) {
	console.log('RESULT:', dataUrl)
});

function toDataURL(url, callback) {
	var xhr = new XMLHttpRequest();
	xhr.onload = function() {
		var reader = new FileReader();
		reader.onloadend = function() {
			callback(reader.result);
		}
		reader.readAsDataURL(xhr.response);
	};
	xhr.open('GET', url);
	xhr.responseType = 'blob';
	xhr.send();
}
Posted by: Guest on August-19-2021
0

Detect Base 64 encoding in images

var base64Matcher = new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$");

// ...

if (base64Matcher.test(someString)) {
    // It's likely base64 encoded.
} else {
    // It's definitely not base64 encoded.
}
Posted by: Guest on August-13-2021

Browse Popular Code Answers by Language