For everyone to introduce a plugin: Jcrop. This plugin is used by me in a number of projects, such as by drawing the heat force to see the number of users of a block, zoom in and out drag box to preview the selected area of the picture disease crop, set the avatar is the box must be a square, it has rich configuration parameters and callback functions.
Its commonly used parameters and callback methods can be found on the Internet, such as whether to allow drag and drop, whether to allow the new marquee, marquee allowed size, color, border, disable the marquee, destroy the marquee, recall the marquee, etc., easy to use.
Use this method:
1. Loading CSS
<link rel="stylesheet" href="jquery.Jcrop.css">
2. Loading JavaScript files
<script src= "jquery.js" > </SCRIPT>
<script src="jquery.Jcrop.js"></script>
3. Add an ID to the IMG tag
<
img
id="element_id" src="pic.jpg">
4. Call Jcrop
$(‘#element_id‘).Jcrop();
For example, to implement the selected area must be a square, you need to write:
$ (' #element_id '). Jcrop ({aspectradio:1});
The aspect ratio is 1 to meet the requirements.
Crop plugin Jcrop