Snapshot Plugin

This plugin enables you to capture an image, a.k.a., a snapshot, of the application user interface including the camera view if the Video Overlay plugin is installed and active. The image is returned as a base-64 encoded JPG or PNG. The snapshot process can be configured to include a single layer or a combination of the Cordova webview and camera view. The snapshot image can be saved to the device photo gallery. Additionally the plugin enables you to save any base-64 encoded JPG or PNG image to the device photo gallery.

This plugin can operate standalone or with the VideoOverlay plugin


Installation

This plugin does not require additional ezAR plugins to be installed for it to operate. But you must install and activate the VideoOverlay plugin if you wish to snapshot a camera preview. The plugin installs using your standard Cordova plugin compliant tools.

   example - from commandline enter
     cordova plugin add path-to-plugins/com.ezartech.ezar.snapshot

Snapshot Use-Cases & Snippets

Create a snapshot

In this snippet the snapshot() function is called with a success callback function that will receive the base-64 encoded snapshot image. An Options object is passed to the plugin configuring it create a PNG encoded image and that the image should be saved to the photo gallery.  

ezar.snapshot(
  function(base64EncodedImage) {
    //do something with snapshot image here
  },
  function(error) {
    alert("ezar snapshot failed");
  },
  {name: "personal-selfie",
   saveToPhotoGallery: true,  //default
   encoding: ezar.ImageEncoding.PNG,
   scale: 50}
  ); 

Saving an image to the photo gallery

ezar.saveToPhotoGallery(
  base64EncodedImage,
  function() {
    //success, do something 
  },
  function(error) {
    alert("ezar saveToPhotoGallery failed");
  }; 

updated 20160620

Plugins
  Video Overlay
  Face Detection
  Snapshot
  Flashlight

 
 

snapshot Plugin JavaScript API

Capture an image of the application user interface. Access the snapshot api through the global ezar.

snapshot(successCB,errorCB,options)

Asynchronously capture a screenshot image of the application user interface in JPG or PNG encoding. Optionally save the image to the device photo gallery. On Android devices,  use the name option to specify a custom filename for the saved image file. Use the boolean includeWebView and includeCameraView options to omit a specific layer in the snapshot image.

parameters

  • successCB  callback function with base64 image parameter (optional)
  • errorCB callback function with String error message parameter (optional)
  • options 
    • saveToPhotoGallery - boolean, default = true
    • encoding - ezar.ImageEncoding.JPG or ezar.ImageEncoding.PNG, default=JPG
    • scale - [1-100] percent of reduction, default=100
    • quality - [1-100] percent of quality, default=50
    • includeWebView - boolean, default=true
    • includeCameraView - boolean, default=true
  • Android-only options
    • name - String, custom name for the image when saved to photo gallery
 
saveToPhotoGallery(base64ImageData,successCB,errorCB)

Save an image in base64 data format to the device photo gallery. Use the options to customize the image scale, quality, format and name. 

parameters

  • base64ImageData - String (required)
  • successCB  callback function (optional), callback parameter: Android - URL of image storage location, iOS - null
  • errorCB callback function with String error message parameter (optional)
  • options
    • encoding - ezar.ImageEncoding.JPG or ezar.ImageEncoding.PNG, default=JPG
    • scale - [1-100] percent of reduction, default=100
    • quality - [1-100] percent of quality, default=50
  • Android-only options
    • name - String, custom name for the image