If this question is repeated then let me know the link of original question because i enable to findout the good link for resolve my current problem.
I am working on phonegap(cordova2.7) camera
and making app for android 4.2.I able to take Multiple Picture's from my app.All image are saving in sd card.But I want to write name on the top of taken picture. i enable to find out how can i resolve this issue.
I want to use only javascript, phonegap method,or plugins.i didnot require any java code. I try to use canvas
var CAM = {};
window.n = 0;
CAM.changePicture = function() {
navigator.camera.getPicture(CAM.onPhotoDataSuccess, CAM.onFail, {
quality : 100,
destinationType : Camera.DestinationType.FILE_URI,
sourceType : Camera.PictureSourceType.CAMERA,
encodingType : 0,
saveToPhotoAlbum : true
});
};
CAM.onPhotoDataSuccess = function(imageURI) {
var c=document.createElement('canvas');
var ctx=c.getContext("2d");
ctx.font = "20px arial";
ctx.drawImage(imageURI,10,10);
ctx.fillText("Hello",30,30);
var gotFileEntry = function(fileEntry) {
var gotFileSystem = function(fileSystem) {
alert(3);
fileSystem.root.getDirectory("AndroidClinic11/"
+ CAMFUNC.folderName(), {
create : true
}, function(dataDir) {
n++;
var newFileName = CAMFUNC.folderName() + " " + n + ".jpg";
fileEntry.moveTo(dataDir, newFileName, null, CAM.onFail);
}, CAM.onFail);
};
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem,
CAM.onFail);
};
window.resolveLocalFileSystemURI(imageURI, gotFileEntry, CAM.onFail);
CAM.changePicture();
};
CAM.onFail = function() {
console.log("failure");
};
You can use a javascript library like fabric which will allow you to save images/text etc so long as you are using the canvas which is possible in phonegap. Here is the documentation for dealing with images. You may need to load the image from the drive depending on how phonegap deals with images from the camera.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With