I'm making a cordova-based application. Is it possible to make a File object with filepath?
What I am going to do is to take a picture and show the picture on a canvas. in android, it works fine but in ios6, the picture corrupted when drawing on a canvas because of mega-fixel problem on ios6.
then I found a plugin below
https://github.com/stomita/ios-imagefile-megapixel
the plugin need a File or Blob argument but I have only file URL. How can I get a File or Blob object from file URL?
my source is below
takePicture : function(onSuccess, onError) {
options = {
quality : 50,
destinationType : navigator.camera.DestinationType.FILE_URI, //device returns File URL
correctOrientation : true
};
navigator.camera.getPicture(onSuccess, onError, options);
}
onSuccess : function (photo_src) {
$('#photo_hidden').attr('src', photo_src);
setTimeout(function() {
copyImage('photo_hidden', 'a04_image');
}, 500);
}
copyImage : function (sourceId, targetId) {
try{
var source = document.getElementById(sourceId);
var source_w = source.width;
var source_h = source.height;
var target = document.getElementById(targetId);
var target_w = target.width;
var target_h = target.height;
target_h = Math.round(target_w / source_w * source_h);
/////////////////////
// I want to make a File object from source.src HERE!!
/////////////////////
//TODO this part will be changed to use plugin
if (target.getContext) {
var context = target.getContext('2d');
context.drawImage(source, 0, 0, source_w, source_h, 0, 0, target_w, target_h);
}
//
}catch (e) {
console.log(e);
}
}
If it is not possible, Any idea to make a File or Blob object is Welcome
Thanks in advance