getPicture


Purpose

Picks a picture from a photo album or takes a picture with the built-in camera.

Signature

getPicture( output, options, callbacks )

Returns

This method does not return anything.

Parameters

Name Description Type Use
output

Passed to set the output configuration. It can be structured as follows:

{
 saveToFile,
 saveToData,
 saveToAlbum
}

Please see the table below for details.

object required
options

Passed to set the configuration for the camera. Default values will be used if the object is empty. It can be structured as follows:

{
 quality,
 imageFormat,
 sourceType,
 url,
 maxWidth,
 maxHeight,
 adaptSizeToOrientation
}

Please see the table below for details.

object required
callbacks

Passed to verify whether the camera was able to capture an image. It can be structured as follows:

{
  onSuccess: function(success) {...},
  onCancel: function() {...},
  onFailure: function(error) {...}
}

object required

The table below lists parameters passed via the output object.

Parameter Description Type
saveToFile

Saves to FileEntry URL or a temporary File API URL if the "url" setting is not specified in the options object. By default it is set to "true".

Boolean
saveToData Indicates whether to return a Data URL or not. By default it is set to "false". Boolean
saveToAlbum Indicates whether to save the photo in a photo album or not. By default it is set to "false". Boolean

The table below lists parameters passed via the options object.

Parameter Description Type
quality

A value from the 0 - 100 range, applies to JPG images only. By default it is set to 100.

Integer
imageFormat

File format to be used to save the image. Possible image types are listed in the Constants table of the Media article. The default setting is JPEG.

Note

On certain devices, the window.launchbox.Media.ImageFormat.PNG setting may result in a delay of up to around 20 seconds before the image is loaded.

String
sourceType Source of the picture. Possible image types are listed in the Constants table of the Media article. The default setting is USER_CHOICE. It displays a native picker that allows to select either a built-in camera or the camera roll. String
url A URL address obtained from the FileEntry object by calling the toURL method. If not provided, a URL address of the current user's temporary storage is generated (if no user account is open, the call fails). String
maxWidth Expected maximum width of the image. The picture will be scaled down to this value, if necessary. If not specified or set to 0, the camera's default image size is used. The setting must be used in combination with the maxHeight option. Integer
maxHeight Expected maximum height of the image. The picture will be scaled down to this value, if necessary. If not specified or set to 0, the camera's default image size is used. The setting must be used in combination with the maxWidth option. Integer
adaptSizeToOrientation If set to "true", the maxWidth will apply to the longer edge of the image regardless of image orientation. By default it's value is "false". Boolean

The table below lists all callbacks supported by the method.

Name Description Return type
onSuccess

Called when the function finishes without an error.

The method's object consists of the following fields:

  • url - A File API URL address, returned if the saveToFile parameter was set to "true".

  • size - Image size in bytes.

  • width - Image width in pixels.

  • heigth - Image heigth in pixels.

  • data - A Data URL, returned if the saveToData parameter was set to "true".

undefined
onCancel Called when the user cancels picking or taking a photo. undefined
onFailure

Called when an error occurs.

The error object contains the description field - a human-readable error description.

undefined

Related topics

Media
Legal notice | Copyright © 2015 and Confidential to Pegasystems Inc. All rights reserved. | Feedback
Advanced...