Get ready to apply a sepia effect to an image acquired using the Media Capture API. Execute the following steps:
Open the command-line tool and create a new PhoneGap project named
ImageEffect
:$ cordova create ImageEffect
Change the path to the newly created project:
$ cd ImageEffect
Add the Media Capture API plugin using the following command:
$ cordova plugin add cordova-plugin-media-capture
Add a
canvas
tag with theid
value as#manipulatedImage
to the existing markup, in order to use it to render the manipulated image:<canvas id='manipulatedImage' />
Once the
deviceready
event has been fired, access the device camera, which allows the user to access only one image:var capture = navigator.device.capture; capture.captureImage(onGetImage, onImageError, {limit: 1});
Define the success handler and access the file information stored in the array that is returned as an argument:
function onGetImage(files){ var currentFile = files[0...