1.4.2 • Published 8 years ago

cordova-plugin-nativecamera v1.4.2

Weekly downloads
12
License
Apache-2.0
Repository
github
Last release
8 years ago

Description

Phonegap plugin which allows the caller to customise a camera preview, including a custom button and overlaying a border image in each corner.

Using the plugin

  • Add the plugin ID and version to the config.xml.
<plugin name="cordova-plugin-nativecamera" />
  • Add custom images for the capture button and borders to your project. The image locations under the Phonegap www directory cannot currently be modified.
PathDescription
www/img/cameraoverlay/border_top_left.pngThe top left border image
www/img/cameraoverlay/border_top_right.pngThe top right border image
www/img/cameraoverlay/border_bottom_left.pngThe bottom left border image
www/img/cameraoverlay/border_bottom_right.pngThe bottom right border image
www/img/cameraoverlay/capture_button.pngThe default image for the capture button
www/img/cameraoverlay/capture_button_pressed.pngThe image for the capture button when tapped
  • Call the plugin from JavaScript. The API is similiar to the Phonegap provided API but currently lacking some of its features.
navigator.customCamera.getPicture(filename, success, failure, [ options ]);
ParameterDescription
filenameThe filename to use for the captured image - the file will be stored in the local application cache. Note that the plugin only returns images in the JPG format.
successA callback which will be executed on successful capture with the file URI as the first parameter.
errorA callback which will be executed if the capture fails with an error message as the first parameter.
optionsAn optional object specifying capture options.

Capture options

OptionDefault ValueDescription
quality100The compression level to use when saving the image - a value between 1 and 100, 100 meaning no reduction in quality.
targetWidth-1The target width of the scaled image, -1 to disable scaling.
targetHeight-1The target height of the scaled image, -1 to disable scaling.

Image scaling

Setting both targetWidth and targetHeight to -1 will disable image scaling. Setting both values to positive integers will scale the image to that exact size which may result in distortion. If the aspect ratio should be respected, supply only the targetWidth or targetHeight and the other will be set based on the aspect ratio.

Example

navigator.customCamera.getPicture(filename, function success(fileUri) {
    alert("File location: " + fileUri);
}, function failure(error) {
    alert(error);
}, {
    quality: 80,
    targetWidth: 120,
    targetHeight: 120
});