ankit
Asked: In: Daily Coding Problems
How to convert base64 image to blob image in ionic?
How to convert base64 image to blob image in ionic?
ionic blob from base64 image | ionic convert base64 to image | convert string to blob javascript | javascript save base64 image to file | how to convert base64 to blob in ionic | blob url from base64
ionic blob from base64 image | ionic convert base64 to image | convert string to blob javascript | javascript save base64 image to file | how to convert base64 to blob in ionic | blob url from base64
ionic blob from base64 image | ionic convert base64 to image | convert string to blob javascript | javascript save base64 image to file | how to convert base64 to blob in ionic | blob url from base64
ionic blob from base64 image | ionic convert base64 to image | convert string to blob javascript | javascript save base64 image to file | how to convert base64 to blob in ionic | blob url from base64
ionic blob from base64 image | ionic convert base64 to image | convert string to blob javascript | javascript save base64 image to file | how to convert base64 to blob in ionic | blob url from base64
ionic blob from base64 image | ionic convert base64 to image | convert string to blob javascript | javascript save base64 image to file | how to convert base64 to blob in ionic | blob url from base64 ionic blob from base64 image ionic convert base64 to image convert string to blob javascript javascript save base64 image to file how to convert base64 to blob in ionic blob url from base64
Share
import { Camera, CameraOptions } from ‘@ionic-native/camera/ngx’;
constructor(private camera: Camera) { }
…
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it’s base64 (DATA_URL):
let base64Image = ‘data:image/jpeg;base64,’ + imageData;
}, (err) => {
// Handle error
});
Convert base64 image to blob image
function dataURItoBlob(dataURI, callback) {
// convert base64 to raw binary data held in a string
var byteString = atob(dataURI.split(',')[1]);
// separate out the mime component
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
// write the bytes of the string to an ArrayBuffer
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
// write the ArrayBuffer to a blob, and you're done
var bb = new Blob([ab]);
return bb;
}