Getting  the image from the album

Using the getPictureFromAlbum function, you can get the image stored in the album.

Method summary

getPictureFromAlbum(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. The default value is false. When it is false, it will return the file URI.

 

Note: If you pass true as a parameter 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 getPictureFromAlbum function:

<cfclientsettings enableDeviceAPI=true>
<cfclient>
<cffunction access="public" name="getPicAlbm" returntype="void" >
<cfset opt = cfclient.camera.getOptions()>
<cfset response = cfclient.camera.getPictureFromAlbum(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('getPicAlbm',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

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy