Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getPhoto(src, target) {
- window.localStorage.removeItem('imageURI');
- var q = 30;
- var imageOutput = target;
- var opts = {
- destinationType: Camera.DestinationType.FILE_URI,
- quality: q
- }
- switch(src) {
- case 'gallery':
- opts.sourceType = Camera.PictureSourceType.PHOTOLIBRARY;
- break;
- default:
- opts.sourceType = Camera.PictureSourceType.CAMERA;
- break;
- }
- function getPhotoFail(msg) { $(imageOutput).attr('src', ''); }
- function getPhotoSuccess(imageURI) {
- window.resolveLocalFileSystemURI(imageURI, resOnSuccess, resOnError);
- function resOnSuccess(entry) {
- console.log('FILE NAME: ' + entry.name);
- entry.file(gotFile, noFile);
- }
- function resOnError(err) {
- navigator.notification.alert('Unable to read file', null, 'FILE ERROR', 'OK');
- }
- function gotFile(file) {
- var bytes = file.size;
- var kb = bytes / 1024;
- console.log('BYTES: ' + bytes);
- console.log('KB: ' + kb);
- window.localStorage.setItem('imageSize', kb);
- // Store the image path for later use
- window.localStorage.setItem('imageURI', imageURI);
- // Display image in <img> element
- $(imageOutput).attr('src', imageURI);
- }
- function noFile(err) {
- }
- }
- // GET PICTURE!
- navigator.camera.getPicture(getPhotoSuccess, getPhotoFail, opts);
- }
Add Comment
Please, Sign In to add comment