angular - 如何将图像的 URL 转换为 base64 (IONIC3)
问题描述
getimage(Type){
let options: CameraOptions;
if (Type == 'camera') {
options = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
};
}
else if (Type == 'gallery') {
options = {
sourceType: this.camera.PictureSourceType.SAVEDPHOTOALBUM,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
};
}
this.camera.getPicture(options).then((img) => {
let base64Image = 'data:image/jpeg;base64,' + img;
this.test(base64Image )
})
test(input:string)
{
let alert = this.alertCtrl.create({
title: input,
subTitle: input,
buttons: ['OK']
});
alert.present();
base64Image 没有输出 base64image 我比较输出的结果和转换相同图像的结果 enligne 并且我的代码输出的结果总是与不同的图像相同
解决方案
推荐阅读
- typescript - 为什么函数表达式和函数声明对一个变量有不同的推断结果?
- python - 如何根据条件在 Python 中对数据帧进行下采样
- ipython - 使用 traitlets 进行配置
- r - 使用 str_ 定位另一个数据帧中众多单词的频率
- java - 无法在项目 XXXX 上执行目标 无法解决项目 XXXX 的依赖关系(兄弟模块案例)
- javascript - 无法加载插件 vue/Eslint 中断
- javascript - 在 raw-body 之后使用 express.json()
- azure-data-factory - 如何将整数存储到 Azure 数据工厂中的变量?
- c++ - libcurl 仅用换行替换回车 + 换行
- django-models - 如何从模型中获取 Django Shell 中的 is_active = False?