David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

save camera image to phone gallery and set name

Hi,

I've read lots of topics and tutorials but still cant find how to use the camera to name and save image to gallery.

Ive successfully saved the image to the apps route folder and used the url to show in an image component. But I need the image in the phones gallery so that the user can find it

thanks for your help

Dave

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

save camera image to phone gallery and set name

Hello David,

Camera component gets you a base64 image. You can save it into the gallery: http://stackoverflow.com/questions/29...

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

save camera image to phone gallery and set name

Hi Sergiy,

Thank you for your help but im a little confused on how to use the code.

Ive added
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {

var fileTransfer = new FileTransfer();
var uri = encodeURI("http://www.example.com/image");
var path = fileSystem.root.toURL() + "appName/example.jpg";

fileTransfer.download(
uri,
path,
function(entry) {
refreshMedia.refresh(path); // Refresh the image gallery
},
function(error) {
console.log(error.source);
console.log(error.target);
console.log(error.code);
},
false,
{
headers: {
"Authorization": "dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
}
);

});

to my on camera service complete, setting uri as my local storage where ive saved my photo location and changed path to "DCIM/example.jpg" but I cant get it to work

thanks

Dave

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

save camera image to phone gallery and set name

Unfortunately custom JS code is something outside the scope of standard Appery.io platform support. You may consider purchasing Advisory Pack to get more in-depth help on this question. Here is more information about Advisory Pack (http://appery.io/services/#Advisory_Pack).

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

save camera image to phone gallery and set name

Hi Sergiy,

Thank you, will look into it. Are Appery.io considering including this function at a later date as using the camera function to save to the gallery seems like a basic/fundamental requirement.

many thanks

Dave

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

save camera image to phone gallery and set name

Hi Sergiy,

Thank you for your help but I've decide not to use the Appery.io camera service and call the plugin through javascript, that way the option to save to gallery is included.

If anyone else has the same issue use this

function capturePhoto() {

navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality : 90,
destinationType : Camera.DestinationType.FILE_URI, ///// same as appery.io /////
sourceType : Camera.PictureSourceType.CAMERA, ///// same as appery.io /////
allowEdit : false, ///// sends photo to phone edit e.g crop /////
encodingType: Camera.EncodingType.JPEG, ///// same as appery.io /////
targetWidth: 1024, ///// same as appery.io /////
targetHeight: 768, ///// same as appery.io /////
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: true }); ///// this saves image to camera gallery folder /////
}

and call the function on a button press

full details are here:
http://docs.phonegap.com/en/edge/cord...

Return to “Issues”