cordova - Phone gap File type from DATA_URL -
how can file properties size, type data_url. using following code.
function getimage() { // retrieve image file location specified source navigator.camera.getpicture(uploadphoto, null, { quality: 50, destinationtype: navigator.camera.destinationtype.data_url, savetophotoalbum: true, sourcetype: 2 }); } function uploadphoto(data) { // here want file type/ size }
is there way this?
i'm afraid can't directly, because picture returned base64 string. however, possible type , size.
type: can define type when setting options making picture cordova plugin. options set encodingtype
. can set to:
camera.encodingtype = { jpeg : 0, // return jpeg encoded image png : 1 // return png encoded image };
size: can calculated simple method this:
var imagebytecount = function (imagestring) { return encodeuri(imagestring) .split(/%(?:u[0-9a-f]{2})?[0-9a-f]{2}|./).length -1; }
however, impossible other information of image. can return image file_uri
or native_uri
, load file file api of cordova. can more information file way.
Comments
Post a Comment