Meteor Camera Package
Add it to your Meteor app with meteor add mdg:camera
. The api is super simple - there is only one function to call.
MeteorCamera.getPicture([options], callback)
Prompt the user to take a photo with their device and get the picture as a Data URI in JPEG format.
options
options
is an optional argument that is an Object with the following possible keys:
width
An integer that specifies the minimum width of the returned photo.height
An integer that specifies the minimum height of the returned photo.quality
A number from 0 to 100 specifying the desired quality of JPEG encoding.
callback(error, data)
callback
is a required argument that is a function that takes two arguments:
error
A Meteor.Error with a platform-specific error message.data
A base64-encoded data URI for the image taken by the camera. This parameter can be used directly in the 'src' attribute of an image tag.
Warning: In the iOS simulator, the device camera is not accessible so you will get an error that says "source type 1 not available." I'm working on a fallback for iOS that will use the photo library when the camera is not available, but for now just test in your web browser, a physical device, or the Android simulator.
Localize
Replace these fields before executing MeteorCamera.getPicture()
like:
1MeteorCamera.locale.errorBrowserNotSupported = "Sorry, this browser is currently not supported for camera functionality."; 2MeteorCamera.locale.errorAccesingCamera = "There was an error accessing the camera."; 3MeteorCamera.locale.usePhoto = "Use Photo"; 4MeteorCamera.locale.takeNewPhoto = "Take New Photo"; 5MeteorCamera.locale.waitingPermissions = "Waiting for camera permissions..."; 6MeteorCamera.locale.takePhoto = "Take Photo"; 7MeteorCamera.locale.cancel = "Cancel"; 8MeteorCamera.locale.closePopup = "Close Popup"; 9MeteorCamera.locale.permissionsDenied = "Camera Permissions Denied"; 10MeteorCamera.locale.permissionsDeniedExp = "You have denied this app permission to use your camera. If you would like to allow permissions, follow the directions for your browser below."; 11MeteorCamera.locale.howToChrome = 'Go to Settings > "Show advanced settings..." > "Content settings..." > Media heading > "Manage exceptions...", then find this website in the list and allow video capture.'; 12MeteorCamera.locale.howToFirefox = "Reload the page and try again."; 13MeteorCamera.locale.howToOpera = 'Go to Preferences > Websites > Media heading > "Manage exceptions...", then find this website in the list and allow video capture.';
with corresponding translations in your language.