, 당신은 ... 캔버스와 서버 측 코드가 아닌 클라이언트 측 될 것
function getBase64Image(img) {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
return canvas.toDataURL("image/png");
}
// if the image is on the dom use this
var img = document.getElementById('img');
alert(getBase64Image(img));
// if the image isn't on the dom do this..
var img = new Image();
img.onload = function(){
alert(getBase64Image(img));
}
img.src= "http://my/image/url.png";
을 그것을 할 수 있습니다. 당신은 실제로 무엇을하려고합니까? – Archer
http://stackoverflow.com/questions/19124701/get-image-using-jquery-ajax-and-decode-it-to-base64/25371174#25371174 – gaetanoM