Easy to use jQuery plugin for zoom & pan image cropping. This plugin is a complete rewrite of https://github.com/blackbiron/jWindowCrop
Visit: http://adriengibrat.github.com/jQuery-crop/
// minimum
$( 'img.crop' ).crop();
// typical
$( 'img.crop' )
.crop( {
width : 300
, height : 300
} )
.on ( 'crop', function( event ) {
console.log( $( this ).attr( 'id' ), 'x: '+ event.cropX );
} );
Option | Type | Default | Required | Description |
---|---|---|---|---|
width | integer | 320 | no | Width in pixels of the cropping window |
height | integer | 180 | no | Height in pixels of the cropping window |
zoom | integer | 10 | no | Number of incremental zoom steps. With the default of 10, you have to click the zoom-in button 9 times to reach 100%. |
loading | string/dom | "Loading..." | no | Text (can be HTML or dom) to display within frame until image is loaded. |
controls | boolean/text | Click to drag | no | If false, no controls will appears. Otherwise controls and text appears mouse hover (using css). |
To get crop results, bind a function on crop event. cropX, cropY, cropW, cropH, stretch (boolean) values are added to the event passed to this function.
A reference to the crop object can be accessed like so:
var crop = $( 'img.crop' ).data( 'crop' );
You then have access to all the properties and methods used for that specific element.