TakePhoto Action

This action invokes a global navigator.camera object to take pictures and/or choose images from the system's image library.

The TakePhoto action module for this action is "vb/action/builtin/takePhotoAction".

The TakePhoto action supports the following optional parameters:

Parameter Name Description
quality Select the quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. Default is 50.
sourceType Set the source of the picture. Possible values are PHOTOLIBRARY, CAMERA, or SAVEDPHOTOALBUM. Default is CAMERA.
targetWidth Width in pixels to scale image. Must be used with targetHeight. Aspect ratio remains constant.
targetHeight Height in pixels to scale image. Must be used with targetWidth. Aspect ratio remains constant.
cameraDirection Choose the camera to use, either front-facing or back-facing. Possible values are BACK or FRONT. Default is BACK.

Example 8-22 Example

The outcome of this action is binary data (blob) representing the captured image. This outcome can then be passed to a REST action for use in uploading the image. 

"takePhotoAction": {
      "root": "takePhoto",
      "actions": {
        "takePhoto" : {
          "module": "vb/action/builtin/takePhotoAction",
          "parameters": {
            "quality": 75,
            "sourceType": "PHOTOLIBRARY",
            "cameraDirection": "BACK",
            "targetHeight": "100",
            "targetWidth": "100"
          },
          "outcomes": {
            "success": "uploadPhoto"
          }
        },
        "uploadPhoto": {
          "module": "vb/action/builtin/restAction",
          "parameters": {
            "endpoint": "imageUpload/postUpload",
            "body": "{{ $chain.results.takePhoto }}"
          }
        }
      }
    }