Cordova camera plugin : FILE_URI option return base64 string

61 views
Skip to first unread message

s@d

unread,
Apr 11, 2017, 12:09:05 PM4/11/17
to phonegap
Help me please. I'm new in Cordova and I have an application using cordova-camera-plugin to take pictures. In camera options i specified destinationType : Camrera.DestinationType.FILE_URI but it still returning a base64 string when i do a console.log

var app = {
    setOptions
: function(srcType, hei, wid ) {
       
var options = {
            quality
: 50,
            targetHeight
: hei,
            targetWidth
: wid,
            destinationType
: Camera.DestinationType.FILE_URI,
            sourceType
: srcType,
            encodingType
: Camera.EncodingType.JPEG,
            mediaType
: Camera.MediaType.PICTURE,
            correctOrientation
: true
       
}
       
return options;
   
},
    cameraSuccess
: function(photo){
        console
.log(photo);
       
var imgcontainer = document.createElement('div');
        imgcontainer
.style.width = "98%";
        imgcontainer
.style.padding = "5px 10px";
       
var newimg = document.createElement('img');
        newimg
.style.margin = "0 auto";
        console
.log(photo);
        newimg
.style.margin = "3px";
        newimg
.style.boxShadow = "3px 3px 5px grey";
        newimg
.style.width = "100%";
        newimg
.style.borderRadius = "3px";
        newimg
.src="data:image/jpeg;base64, "+photo;
       
//newimg.src=photo;
        imgcontainer
.appendChild(newimg);
        document
.querySelector("#an-photos div").appendChild(imgcontainer);
   
},
    cameraError
: function(photo){
           
        app
.navigator.camera.cleanup();
   
}
}

document
.querySelector("ons-button#pub-add-photos").addEventListener("click", function(){
    navigator
.camera.getPicture(app.cameraSuccess, app.cameraError, app.setOptions(Camera.PictureSourceType.CAMERA,150, 200 ));
});


Reply all
Reply to author
Forward
0 new messages