UI component to facilitate setting a profile picture (à la Trello): Snap a webcam pic, crop it: nang profile pic.
First, Component must be installed as a prereq.
Then,
$ component install brettbukowski/iconic
Check the example.html file for a demo.
If you don't want to use component, include the .min.js file on the page:
<script src="build/iconic.min.js"></script>
And the CSS:
<link rel="stylesheet" type="text/css" href="build/iconic.css">
This is basically a glue wrapper around the sensorium and cropper components.
Require and create a new instance.
var Iconic = require('iconic'),
iconic = new Iconic('#my-image');
The first parameter is a selector / HTMLElement to place the control into.
All options specified in the optional second param hash pass thru to sensorium and cropper.
iconic.startCapture();
Starts sensorium's getUserMedia process.
All events from sensorium and cropper are propagated out thru iconic.
When the user finally confirms a cropped image to use, the cropped
event is fired.
iconic.on('cropped', function (uri) {
var img = document.createElement('img');
img.src = uri;
img.addEventListener('load', function () {
document.body.appendChild(img);
// Now is when you'd send the base64 data string off to the server...
});
});
Copyright (c) 2013 Brett Bukowski
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.