如何将iamge转换为数据uri ionic [英] How to convert iamge to data uri ionic
本文介绍了如何将iamge转换为数据uri ionic的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个相机应用程序。在我拍摄照片后,我需要将该图像转换为数据uri然后必须发送到数据库。
I am using one camera app. In that after i took photot i need to convert that image to data uri and then have to send to db.
这是我做的:
function opencamer() {
console.log("camer open");
Camera.getPicture().then(function(imageURI) {
console.log(imageURI);
$scope.lastPhoto = imageURI;
$scope.imgUrl = "data:image/jpeg;base64," + imageURI;
}, function(err) {
console.err(err);
}, {
quality: 75,
targetWidth: 320,
targetHeight: 320,
saveToPhotoAlbum: false
});
}
但是当我发送此<$ c时$ c> $ scope.imgUrl 到db。我无法获得数据uri.please帮助我如何解决这个问题。
but when i sent this $scope.imgUrl
to db. i was not able to get data uri.please help me out how can i solve this.
我卡车超过3小时。无法找到解决方案。请帮助我。
i am truck more than 3 hr. not able to find solution.please help me out.
谢谢
推荐答案
以下是工作代码
$scope.opencamer= function () {
var options = {
quality: 75,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 300,
targetHeight: 300,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function (imageURI) {
$scope.lastPhoto = imageURI;
$scope.imgUrl = "data:image/jpeg;base64," + imageURI;
}, function (err) {
// An error occured. Show a message to the user
});
}
发送 $ scope.lastPhoto
到你的db而不是 $ scope.imgUrl
send $scope.lastPhoto
to your db instead of $scope.imgUrl
这篇关于如何将iamge转换为数据uri ionic的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文