Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async takePicture() {
let isAvailable = true;
if (!isAvailable) {
// Have the user upload a file instead
alert("No Camera Aailable");
} else {
// Otherwise, make the call:
try {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: true,
resultType: CameraResultType.DataUrl,
source: CameraSource.Prompt
});
console.log("image", image);
// image.base64_data will contain the base64 encoded result as a JPEG, with the data-uri prefix added
this.imageUrl = image.dataUrl;
// can be set to the src of an image now
console.log(image);
} catch (e) {
console.log("error", e);
}
}
}
}
async testAndroidBreak() {
const image = await Plugins.Camera.getPhoto({
allowEditing: false,
correctOrientation: true, // <------------ oups
height: 1080,
width: 1080,
quality: 90,
resultType: CameraResultType.DataUrl,
saveToGallery: false,
source: CameraSource.Photos
});
console.log('Got image back', image.path, image.webPath, image.format, image.exif);
this.image = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
}
}