You are here:
getPictureAsync({Object}cameraSettings, {String}source)
Loads the device's default camera and gets the image URI. It can also read images from the device image gallery.
Required Editions
| Available in Lightning Experience in Professional, Unlimited, and Enterprise Editions that have Consumer Goods Cloud enabled. |
Parameters
- cameraSettings
- Type: JSON Object
- Contains two properties:
quality: Defines the quality of the image captured. It must be a number from 0 through 100. Value 100 provides full resolution with no loss from file compression whereas value 0 provides a low-resolution image. Any other value is invalid. The default value as 40.encodingType: Defines the encoding type of the image returned. The value of the parameter must be a string either 'jpeg' or 'png'. Any other values are considered invalid. The default value is 'jpeg'.
- source
- Type: String
- Determines whether the camera is used or the built-in image library is used. The
values of this parameter are CAMERA, IMAGE_LIBRARY, or null. Both the values CAMERA and
IMAGE_LIBRARY are stored in the IMAGE_SOURCE. The
getPictureFromLibraryAsyncAPI calls thegetPictureAsyncAPI with the parameter IMAGE_LIBRARY to read images from the device image gallery. If the IMAGE_LIBRARY parameter is used, then the returned image is copied instead of getting moved to the applications temporary cache folder. The supported types of the copied image are either 'jpeg' or 'png'. Images of type other than 'jpeg' or 'png' are rejected. Also, if the image file is larger than 10 MB, it's rejected.
Return Value
A promise. If invalid input parameters are provided, the promise is rejected.
Example
Facade.getPictureAsync({quality:20, encodingType:'jpeg'}).then(
function(imageURI) {
// Do something with the image url provided ;
// In Android, example imageURI = file:///storage/emulated/0/Android/data/com.salesforce.industries.offlineapp/cache/1395835803979.jpg
// In ios, example imageURI = file:///var/mobile/Applications/7D13E650-ACE8-43A0-B23B-1825A5231C2D/tmp/cdv_photo_002.jpg
},
function(err) {
console.log(err);
});
Did this article solve your issue?
Let us know so we can improve!

