Chinese API document address: http://code.ciaoca.com/jquery/jcrop/
Simple to use cropping:
<! DOCTYPE html> Lang= "en" > < Head> <metaCharSet= "UTF-8" > <title> Cutting Plug-in </title> <!--must introduce css--> <link rel= "stylesheet"href= "./jcrop/css/jcrop.min.css" > <style>/*.box {width:600px;
height:400px;
Background:pink; }*/</style> </ Head> < Body> <!--<div class= "box" ></div>--> <div class= "box" > src= "Aa.jpg"alt= "" > </div> <scriptsrc=".. /jquery/jquery.js "></script> <!--Windows is case-insensitive--> <!--Linux is differentiated--> <scr Iptsrc= "./jcrop/js/jcrop.min.js" ></script> <script>//There is a need//width ratio of 2//any size of the picture, the default selection Area horizontally covered, vertically centered$(' img '). Jcrop ({//Setselect: [10, 10, 100, 100]//the first set of mode, the value is deadAspectratio: 2,//wide/high proportionBoxwidth: 400,//Control box width//bgcolor: ' Red ',canresize: false}, Function () {//callback this method when the trim plug-in executes successfullyConsole. log (' plugin executed ... ');
This refers to an instance of the current plug-in//Console.log (this); There are some methods on this instance to use//original picture width//this.ui.stage.width//this.ui.stage.height var w = this.ui .Stage. width, h = w/2, x = 0, y = (this.ui.Stage.Height-h)/2;Console. log (this);
Open a new constituency this.newselection ();
This.setselect ([x, Y, W, h]);//The second set mode value is can be set to get the}); Event to hear the parent element$('. Box '). On (' Cropstart cropmove cropend ', function (E, S, c) {//Console.log (E.type);Console. log (c);
}); </script> </ Body>
With preview code when intercepting:
<! DOCTYPE html> Lang= "en" > < Head> <metaCharSet= "UTF-8" > <title> Cutting Plug-in </title> <link rel= "stylesheet"href= "./jcrop/css/jcrop.min.css" > <style>/*.box {width:600px;
height:400px;
Background:pink;
}*/. jcrop-thumb {right:0;
top:0;
}. thumb {width:300px;
height:400px;
Position:absolute;
top:0;
right:0;
Background:pink; } </style> </ Head> < Body> <!--<div class= "box" ></div>--> <div class= "box" > src= "Bb.jpg"alt= "" > </div> <div class= "thumb" ></div> <scriptsrc=".. /jquery/jquery.js "></script> <!--Windows is case-insensitive--> <!--Linux is differentiated--> <scr Iptsrc= "./jcrop/js/jcrop.js" ></script> <script>//A picture with a need//width ratio of 2//size, default selection level Full, vertically centered$(' img '). Jcrop ({//Setselect: [10, 10, 100, 100]//Set the aspect ratio of the selectionAspectratio: 2,//Set the width of the pictureBoxwidth://bgcolor: ' Red ',//can be resized//canresize:false}, function () {//when the trim plugin executes into After work callback this methodConsole. log (' plugin executed ... ');
This refers to an instance of the current plug-in//Console.log (this); There are some methods on this instance to use//original picture width//this.ui.stage.width//this.ui.stage.height var w = this.ui .Stage. width, h = w/2, x = 0, y = (this.ui.Stage.Height-h)/2;
New constituency this.newselection ();
Sets the new selection coordinate this.setselect ([x, Y, W, h]); This.initcomponent (' Thumbnailer ', {width: 240,Height: 120,Thumb: '. Thumb '});
}); Event to hear the parent element$('. Box '). On (' Cropstart cropmove cropend ', function (E, S, c) {//Console.log (E.type); The C parameter can be used to get the cut after the inchConsole. log (c);
}); </script> </ Body>