cfclient.camera.getPictureFromPhotoLi

Getting  the image from the photo library

Using the getPictureFromPhotoLibrary function, you can get the image stored in the photo library.

Method summary

getPictureFromPhotoLibrary(Options, base64)

  • returns – Returns the 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.

 

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.

 

 

The following example shows how you can get an image from the local file system using the getPictureFromPhotoLibrary function:

<cfclientsettings enableDeviceAPI=true>
<cfclient>
<cffunction access="public" name="getPicCam" returntype="void" >
<cfset opt = cfclient.camera.getOptions()>
<cfset response = cfclient.camera.getPictureFromPhotoLibrary (opt,true)>

<cfset response ='data:image/jpeg;base64,'+ response>
<cfset src_to_img("myimg", response)>
</cffunction>

</cfclient>

<button style="width:100;height:50" onclick="invokeCFClientFunction(' getPicCam',null)">Get a picture
</button>

<img style = "width:200; height:100;" id = "myimg"></img>

<script type="text/javascript">
function src_to_img(img_id,data_to_write)
{
document.getElementById(img_id).src=data_to_write;
}
</script>

 

Example

 

See Using the Camera APIs

Get help faster and easier

New user?