0

I want to convert a file url to data uri. please help on this. Im trying a phonegap app in which i am taking pic from camera and upload. but when i'm using datauri it crashes due to memory leak issue. so i'm trying to do in file url way.

Jagan C
  • 66
  • 12
  • You'll need to display some code of what you have tired my friend – Jamie Hutber Apr 25 '14 at 10:16
  • Hi i am also facing this issue set camera quality in android less than 30.... this is convert to file_url to data_url after camera success [refer](http://stackoverflow.com/questions/20280911/encoding-a-image-to-base64-and-upload-to-web-service-in-phonegap/22910216#22910216) this example convert your file size upto **6mb** . if you use more than 6 mb file means here also get **out of memory** error.. – Kathir Apr 25 '14 at 10:27

1 Answers1

0

your app crash is not because of DATA_URL, it is because your image is too big to upload. try my code for your problem. You need to set quality below 50 and make sure reduce width and height. Use FILE_URI instead DATA_URL.

function capturePhoto() {
        // Take picture using device camera and retrieve image as base64-encoded string
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
            quality: 30,
        targetWidth: 600,
        targetHeight: 600,
        destinationType: navigator.camera.DestinationType.FILE_URI,
        saveToPhotoAlbum: true,
        correctOrientation: true
    });
}
Nurdin
  • 23,382
  • 43
  • 130
  • 308