Skip to content

Instantly share code, notes, and snippets.

@Sampath-Lokuge
Created June 4, 2018 12:17
Show Gist options
  • Save Sampath-Lokuge/6d896433740f309759f40e4213e43c23 to your computer and use it in GitHub Desktop.
Save Sampath-Lokuge/6d896433740f309759f40e4213e43c23 to your computer and use it in GitHub Desktop.
Photo
//take Photo
takePhoto(sourceType: number) {
const options: CameraOptions = {
quality: 50,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
correctOrientation: true,
sourceType: sourceType,
}
this.camera.getPicture(options).then((imageData) => {
let base64Image = 'data:image/jpeg;base64,' + imageData;
let photo = new Photo();
let id = random(1, 12);
photo.id = id;
photo.url = base64Image;
if (this.data == null) this.data = [];
this.data.push(photo);
}, (err) => {
// Handle error
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment