无题
转换 document.getElementById(“exchangeBtn_20171124”).onclick = function(){ url2base64(document.getElementById(“input_20171124”).value) }; function convertImgToBase64(url, callback, outputFormat){ var canvas = document.createElement(‘CANVAS’), ctx = canvas.getContext(‘2d’), img = new Image; img.crossOrigin = ‘Anonymous’; img.onload = function(){ canvas.height = img.height; canvas.width = img.width; ctx.drawImage(img,0,0); var dataURL = canvas.toDataURL(outputFormat ‘image/png’); callback.call(this, dataURL); canvas = null; }; img.src = url; } function url2base64(url){ convertImgToBase64(url, function(base64Img){ // Base64DataURL document.getElementById(“base64_output_20171124”).value = base64Img; }); }
无题
http://example.com/2017-11-24/