Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
cordova-plugin-camera-preview
Advanced tools
Cordova plugin that allows camera interaction from HTML code. Show camera preview below or on top of the HTML.
Cordova plugin that allows camera interaction from HTML cod for showing camera preview below or above the HTML.
Apr 27, 2016 - Plugin is starting to be maintained again, current development to get a decent stable version is happening on the branch skanygin. Please direct all pull requests here until further notice.
Features:
Installation:
cordova plugin add https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview.git
Phonegap Build:
<gap:plugin name="cordova-plugin-camera-preview" />
Methods:
startCamera(rect, defaultCamera, tapEnabled, dragEnabled, toBack)
Starts the camera preview instance.
When setting the toBack to TRUE, remember to add the style bellow on your app's HTML body element:
style="background-color='transparent'"
Javascript:
var tapEnabled = true; //enable tap take picture
var dragEnabled = true; //enable preview box drag across the screen
var toBack = true; //send preview box to the back of the webview
var rect = {x: 100, y: 100, width: 200, height:200};
cordova.plugins.camerapreview.startCamera(rect, "front", tapEnabled, dragEnabled, toBack)
stopCamera()
Stops the camera preview instance.
cordova.plugins.camerapreview.stopCamera();
takePicture(size)
Take the picture, the parameter size is optional
cordova.plugins.camerapreview.takePicture({maxWidth:640, maxHeight:640});
setOnPictureTakenHandler(callback)
Register a callback function that receives the original picture and the image captured from the preview box.
cordova.plugins.camerapreview.setOnPictureTakenHandler(function(result){
document.getElementById('originalPicture').src = result[0];//originalPicturePath;
document.getElementById('previewPicture').src = result[1];//previewPicturePath;
});
switchCamera()
Switch from the rear camera and front camera, if available.
cordova.plugins.camerapreview.switchCamera();
show()
Show the camera preview box.
cordova.plugins.camerapreview.show();
hide()
Hide the camera preview box.
cordova.plugins.camerapreview.hide();
Base64 image:
Use the cordova-file in order to read the picture file and them get the base64.
Please, refer to this documentation: http://docs.phonegap.com/en/edge/cordova_file_file.md.html
Method readAsDataURL: Read file and return data as a base64-encoded data URL.
Sample:
Please see the CordovaCameraPreviewApp for a complete working example for Android and iOS platforms.
Android Screenshots:
FAQs
Cordova plugin that allows camera interaction from HTML code for showing camera preview below or on top of the HTML.
We found that cordova-plugin-camera-preview demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.