Croppie is a fast, easy to use image cropping plugin with tons of configuration options!
var c = new Croppie(document.getElementById('item'), {
viewport: {
width: px,
height: px,
type: 'square|circle' //default 'square'
},
boundary: {
width: px,
height: px
},
customClass: '',
showZoom: true|false, //default true
mouseWheelZoom: true|false, //default true
update: function (cropper) { }
});
// bind an image to croppie
c.bind({
src: 'path/to/image',
points: [x1, y1, x2, y2]
});
// get crop points from croppie
var data = c.get();
// get result from croppie
// returns Promise
var result = c.result('html|canvas').then(function (img) {
//img is html positioning & sizing the image correctly if resultType is 'html'
//img is base64 url of cropped image if resultType is 'canvas'
});
Or you can use jquery
$('#item').croppie(opts);
$('#item').croppie(method, args);
The outer container of the cropper
A class of your choosing to add to the container to add custom styles to your croppie
Enable or disable the ability to use the mouse wheel to zoom in and out on a croppie instance
Hide or Show the zoom slider
The inner container of the coppie. The visible part of the image
Get the crop points, and the zoom of the image.
Bind an image the croppie. Returns a promise to be resolved when the image has been loaded and the croppie has been initialized.
Get the resulting crop of the image. resultType can be 'canvas' or 'html'. 'canvas' returns a base64 image. 'html' returns html of a image cropped by positioning within a div.
when the croppie is dragged around or zoomed, update is fired.
var basic = $('#demo-basic').croppie({
viewport: {
width: 150,
height: 200
}
});
basic.croppie('bind', {
url: 'demo/cat.jpg',
points: [77,469,280,739]
});
//on button click
basic.croppie('result', 'html');
var vanilla = new Croppie(document.getElementById('vanilla-demo'), {
viewport: { width: 100, height: 100 },
boundary: { width: 300, height: 300 }
});
vanilla.bind('demo/demo-2.jpg');
//on button click
vanilla.result('canvas');
$uploadCrop = $('#upload-demo').croppie({
viewport: {
width: 200,
height: 200,
type: 'circle'
},
boundary: {
width: 300,
height: 300
}
});
Croppie was built by Foliotek for use in Foliotek Presentation.
Check out some of our other open source tools: AjaxQ | LTI Tester