pui.capturePhoto( config )



This API takes a picture using a mobile device and uploads it to the IFS on the IBM i.  It is made to work with an application packaged with PhoneGap/Apache Cordova, including Profound's Mobile App.

The security for this API is managed through the File Upload Exit Program (PUIUPLEXIT).  You must create the program before using this API.  For more details, refer to the File Upload Security Page.

Parameters:

  • config object - JavaScript object containing configuration properties. These properties can be thought of as belonging to two different camps: some control pui.capturePhoto itself and others are passed along to the underlying Cordova camera plugin to allow you to further customize camera settings.

Configuration Options:

pui.capturePhoto properties

  • dir - the IFS directory to upload the image to; if not specified, the image is uploaded to /www/profoundui/htdocs/profoundui/userdata/images

  • fileName - the IFS file name for the image; the default value is "image.jpg"

  • overwrite - true or false value specifying whether the image file should be overwritten if it already exists; the default value is false

  • handler - JavaScript function to handle the result of the operation; if not provided, nothing will happen on success, and an error message will be alerted on failure. The function will receive a configuration object with the following properties:

    • success - true or false value indicating whether the photo was captured and uploaded successfully

    • error - error message; present only if success if false

    • bytesSent - number of bytes sent

    • responseCode - the HTTP response code

Cordova camera plugin properties (not all properties work with all devices; see plugin documentation for more details) 

  • quality - specifies the image quality; the default value is 50; valid values are 0 to 100

  • allowEdit - boolean value to allow simple editing of the image before selection; the default value is false

  • encodingType - the image format of the returned image; the default value is JPEG

  • targetWidth - numeric value that specifies the width in pixels to scale image. Must be used with targetHeight property. Aspect ratio remains constant.

  • targetHeight - numeric value that specifies the height in pixels to scale image. Must be used with targetWidth property. Aspect ratio remains constant.

  • correctOrientation - boolean value to control rotation of the image to correct for the orientation of the device during capture; the default value is true

  • saveToPhotoAlbum - boolean value to control saving the image to the photo album on the device after capture

  • cameraDirection - the camera to use (front- or back-facing); the default is BACK

Note: Profound UI versions 6.2.1 and lower only support the following camera plugin properties: quality, targetHeight, and targetWidth.

Example:

The following example initiates a photo capture and submits the screen if the capture is successful.  Otherwise, an error message is displayed.

pui.capturePhoto({ dir: "/www/profoundui/htdocs/my images/", fileName: "photo.jpg", overwrite: true, handler: function(response) { if (response.success) { pui.click(); } else { alert(response.error); } } });



Example:

The following example initiates a photo capture and returns a thumbnail image (the image is resized to thumbnail size).

pui.capturePhoto({ dir: "/www/profoundui/htdocs/my images/", fileName: "thumbnail.jpg", overwrite: true, targetHeight: 100, targetWidth: 100 });