I'm currently using ionic 5 and cordova.
I use https://ionicframework.com/docs/native/camera to access my photo galary in ios device.
AIM: Default ios captures .heic type image i want to convert selected image to .jpeg and then that .jpeg need to be converted to base64
this is my camera options:
const options: CameraOptions = {
quality: 50,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
};
this.camera.getPicture(options).then((dataUrl) => {
console.log('imageUri : ', dataUrl);
this.imageToBase64(dataUrl)
.subscribe((res: Blob)=>{
const ref = this;
const reader = new FileReader();
reader.readAsDataURL(res);
reader.onload = ()=>{
console.log('reader',reader);
ref.base64 = reader.result.toString();
};
});
console.log('imageToBase64',this.base64);
});
imageToBase64(img): Observable<any>{
return this.httpClient.get(img,{responseType: 'blob'});
}