Cordova is a mobile application development framework Owned by Adobe System, it was first created by Nitobi but in 2011 Adobe System acquires/purchases it. Earlier Crodova is known as PhoneGap. It is a free and open source version of Apache Crodova whose main goal is to develop a mobile app without the knowledge and use of mobile programming languages "Android, iOS", Only using of HTMl, CSS and JavaScript.
In today's topic, we will discuss Cordova picture background plugin for more on PhoneGap you can veiw other tutorials from "http://findnerd.com/NerdDigest/PhoneGap/".
let's come to the topic back, Basically this plugin captures an image without user interaction and allows to capture an image without open device camera. You will find the captured image in device external storage. This plugin supports Android platform only.
First of all, We need to install Cordova picture background plugin in our PhoneGap project through CLI:
Cordova plugin add https://github.com/an-rahulpandey/cordova-plugin-camerapicturebackground.git
Plugin Usage:
var options = {
name: "myImage", //image suffix
dirName: "CameraPictureBackground", //foldername
orientation: "landscape", //or portrait
type: "back" //or front
};
window.plugins.CameraPictureBackground.takePicture(success, error, options);
function success(imgurl) {
console.log("Imgurl = " + imgurl);
}
In the above code, window.plugins.CameraPictureBackground.takePicture invokes the device camera.
We can define some options also :
name: It defines the name of captured image. For ex. In the above code, myImage will be the name of captured image.
DirName: In device external storage this will be the name of the folder in which captured image will be stored.
Orientation: When taking a picture we can define its orientation i.e landscape or portrait.
Type: Defines the camera type i.e front or back camera.
Hope this will help you, for any quires feel free to write in comment section below.
0 Comment(s)