ionic imgBase64

navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: ,        destinationType: destinationType.DATA_URL,targetWidth: ,targetHeight: ,correctOrientation:true });
function onPhotoDataSuccess(imageData) {
saveImageToDB(imageData,);
smallImage1.style.display = 'block';
smallImage1.src = "data:image/jpeg;base64," + imageData;
}
var imagePath = "img/OBseverLOGO.png";
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,,);
var dataURL = canvas.toDataURL(outputFormat || 'image/png');
callback.call(this, dataURL);
canvas = null;
};
img.src = url;
} //这里的imagePath用你的图片路径来替换; convertImgToBase64(imagePath, function(base64Img){
alert(base64Img.length);
});
上一篇:【PYTHON】用户登录三次错误锁定


下一篇:最小化安装centos7不能执行ifconfig命令的解决方法