Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Retrieving thumbnail of an image taken with a PS 2.0 Camera API

From Wiki
Jump to: navigation, search

This article explains how to retrieve thumbnail of an image taken with a PS 2.0 Camera API

Article Metadata
Code ExampleTested with
Devices(s): Nokia C7-00, Nokia N97
Platform(s): Symbian^1 and later
Device(s): Symbian Devices supporting PS 2.0
Keywords: getThumbnail()
Created: isalento (01 Mar 2012)
Last edited: hamishwillee (05 Jul 2012)



Platform Services (PS) 2.0 Camera API can be used to take an image by using device’s native camera application. However the captured image is not suitable to be used in widgets native size, as it is simply too large to be presented. PS 2.0 offers an API to solve this problem. Media Management API has getThumbnail() method which can retrieve an thumbnail image of the captured image.

Taking picture

Taking picture, with the PS 2.0 Camera API is straightforward. In the success-callback handler, we pass the URI of the captured image, to getThumb() method. Please note that PS 2.0 Camera API has issues with Non English devices. In addition there is a change in handling widget.onshow event, in WRT 7.3 (Browser 7.3). Please use tweaked platformservices.js file, from attached example application, to address these problems. Also See Managing Platform Services 2.0 permissions prompts to how to reduce amount of prompts shown to the user.

var camera_so;
function camera_takePicture_error_callback(err){
alert("Error Code:" + err.code + " Error Message:" + err.message);
function camera_takePicture_callback(picture_array){
//actually in case of success, the lenght of the array is 1, no more
for (var i = 0; i < picture_array.length; i++) {
* Takes a picture with a native camera application

function camera_takePicture(){
try {
camera_so = nokia.device.load("camera");
//launch native camera application and retreive the captured image
var transactionID = camera_so.startCamera(camera_takePicture_callback, camera_takePicture_error_callback);
}catch (e) {

Get Thumbnail

Thumbnail image is obtained by using PS 2.0 Media management API. One important aspect to note is, file URI returned by Camera API, has preceding file:///, where as Media Management API expects file://. Thumbnail retrieving is demonstrated in the code below.

// ErrorCallback function
function errorCB(err){
alert("ErrorCode: " + err.code + " ErrorMessage: " + err.message);
// callback function
function showThumb(uri){
document.getElementById("photo").src = uri;
* Extracts thumbnail from image, taken with a camera

function getThumb(image_uri){
try {
thumbso = nokia.device.load("media");
// strip file:/// and replace with file://
image_uri = image_uri.substring(8, image_uri.length);
image_uri = "file://"+image_uri;
//define thumbnail size
var thumb={
uri: image_uri,
width: 200,
height: 150
var transactionId = thumbso.getThumbnail(showThumb, thumb, errorCB);
catch(e) {

Example Widget

Media: CameraThumbnail.wgz

This page was last modified on 5 July 2012, at 02:31.
23 page views in the last 30 days.