jQuery comes with a number of handy plugins to enhance the functionality of web controls. For applications requiring image cropping, a plugin called JCrop can be used with the Image control. In this recipe, we will use this plugin to crop images and display the co-ordinates of the crop area.
Add a new web form
Recipe6.aspx
to the current project.Download the JCrop plugin from http://deepliquid.com/content/Jcrop.html.
Save the
jquery.Jcrop.js
file to the localjs
folder. Save the stylesheet filejQuery.Jcrop.css
to the stylesheet foldercss
:Add both the files we just saw to the page along with the jQuery library:
<link href="css/jquery.Jcrop.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.4.1.js" type="text/javascript"></script> <script src="js/jquery.Jcrop.js" type="text/javascript"></script>
Add the following css class for the image:
.image { position:relative; width: 400px; ...