Note: The image quality of pictures taken using the camera on newer devices is quite good, and images from the Photo Album will not be downscaled to a lower quality, even if a quality parameter is specified. Encoding such images using Base64 can cause memory issues on many newer devices. Therefore, using FILE_URI for images captured is highly recommended. |
Getting the image from the camera
By invoking the default camera application on the device, this function takes a photo using the camera as the source.
The following example shows how you can get an image from the camera using the getPicture function:
<cfset picture = cfclient.camera.getPicture(options, base64)> |
The following example depicts the usage:
<cfclientsettings enableDeviceAPI=true> |
In the above example, on the click of a button, the default camera application is opened and after capturing an image, the image is rendered in the <img> tag.
Note: If you pass true as a param indicating that the returned object should be a Base-64 encoded string, its content has to be prefixed with “data:image/jpeg;base64,” before rendering it.
Method summary
getPicture(Options, base64)
- returns – Returns the image file URI or a Base-64 encoded string
- params
- Options – Object
- base64 – A Boolean flag to indicate that the returned object should be a base-64 encoded string.
Format for the Options object
The following table has the list of the properties for the Options object (ColdFusion sets defaults for these properties):
Property |
Type |
allowEdit |
Boolean |
encodingType |
JPEG or PNG |
popoverOptions |
Object |
savePhotoToAlbum |
boolean |
Quality |
Number (0-100) |