Skip to content

Instantly share code, notes, and snippets.

@m5rk
Created July 26, 2016 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m5rk/d8747b8be7c6187f600781c7bdb27fab to your computer and use it in GitHub Desktop.
Save m5rk/d8747b8be7c6187f600781c7bdb27fab to your computer and use it in GitHub Desktop.
// When Cordova is not present Camera.getPicture() will throw an exception.
// Catch that and use your fixture image...
public takePicture(): void {
Camera.getPicture(options)
.then((data) => {
let base64Image: string = 'data:image/jpeg;base64,' + data;
this.save(base64Image);
})
.catch(() => {
// openssl base64 -in small.png -out small.txt
let base64Image: string = `data:image/png;base64,' + contents of small.txt
this.save(base64Image);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment