Skip to content

Instantly share code, notes, and snippets.

@bhuber
Created Jan 27, 2012
Embed
What would you like to do?
Phonegap Camera Function
var defaultPictureOptions = {
quality : 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA
/* ,
targetWidth: 100,
targetHeight: 100
*/
};
var phonegapPic = function(onSuccess, onFail, photoType) {
if (!navigator) { console.log('no navigator obj'); return false; }
if (!navigator.camera) { console.log('no navigator.camera obj'); return false; }
if (!navigator.camera.getPicture) { console.log('no navigator.camera.getPicture'); return false; }
photoType = photoType || "camera";
console.log('taking picture...');
var opts = $.extend({}, defaultPictureOptions, {
sourceType: (photoType === "camera") ? Camera.PictureSourceType.CAMERA : Camera.PictureSourceType.PHOTOLIBRARY
});
navigator.camera.getPicture(onSuccess, onFail, opts);
return true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment