Take a picture and save on the telephone?

Hi

I’m new to Angular/Iconic and I was wondering … is it possible to build an app that

  1. takes picture
  2. save the picture on the device (for example to camera roll)

I searched and I found this : Newbie Question - How to implement camera functions to take the picture

But I haven’t found anything yet to save the picture.

Hello!

If you are using ngCordova, you can set the property saveToPhotoAlbum: true.

On iOS, the app will ask for permission to save to camera roll on the first time.

DOCS: Cordova Camera Docs

1 Like

so as I understand … Iconic uses Cordova right? So I could use Cordova Camera with Iconic?

//edit
ah … I see it now …

Did you managed to make it work ? :smile:

sorry for necro this post, but i’ve searched and this post seemed the best place to ask…

I’ve been working with the cordova camera plugin lately with and without ng.cordova, and looks like the saveToPhotoAlbum setting is not working for me.

Working on android 4.4

If you, or anyone can help me to find the issue, i’d be very apreciated.

thanks

Could you post your code here?

The same code run on iOS?

Of course @felipew , my code is the one provided by ngCordova.

$scope.takePicture = function() {
var options = { 
    quality : 80, 
    destinationType : Camera.DestinationType.DATA_URL, 
    sourceType : Camera.PictureSourceType.CAMERA, 
    allowEdit : true,
    encodingType: Camera.EncodingType.JPEG,
    targetWidth: 640,
    targetHeight: 640,
    //popoverOptions: CameraPopoverOptions,
    saveToPhotoAlbum: true,
    correctOrientation: true
};

$cordovaCamera.getPicture(options).then(function(imageData) {
  // Success! Image data is here
  $scope.data.foto = "data:image/jpeg;base64,"+imageData;

}, function(err) {
  // An error occured. Show a message to the user
});
}

I’ve only tested it on android. And everything works right, except that the picture is not saved on the camera roll or anywhere apparently.

Also, as a side comment, even on a good phone, when i do <img src="$scope.data.foto"> with the base64 image, the app suffers a big performance loss. Any advices on this?

Your app have the correct permission to save to the camera roll?

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

I’ve don’t checked it, but its very likely to be this.
I just downloaded the plugin via the CLI and didn’t check the app permissions.
I’ll try it this afternoon.

Thanks!

sorry for doublepost, but the permission was set and the picture is not saving on the camera roll or any know folder.

change destinationType from DATA_URL to FILE_URI and it saves to device cameraroll

1 Like

thanks for your reply.
Just a question: if I set DATA_URL to FILE_URI i won’t get the image on base64 string, will I?

nope, you wouldnt have it as base64

Thank you, but i think i will pass then.