1

i'm new in jQuery. and I'm trying to crop a picture using the jcrop plugin.
Here is my current code:

jQuery(document).ready(function () {
    var width = '<%=Session["imageWidth"]%>';
    var height = '<%=Session["imageHeight"]%>';

    jQuery('#imgCrop').Jcrop({
        boxWidth: 800, 
        boxHeight: 600,
        onSelect: storeCoords,
        bgColor: 'pink',
        bgOpacity: .6,
        setSelect: [0, 0, width, height],
        aspectRatio: 1
    });

});

function storeCoords(c) {
    jQuery('#X').val(c.x);
    jQuery('#Y').val(c.y);
    jQuery('#W').val(c.w);
    jQuery('#H').val(c.h);
};

Here everything is ok but the selection area is resizable.
What should I change in order to fix the selection area and stop the new selection?

gion_13
  • 41,171
  • 10
  • 96
  • 108
Nahid Nafi
  • 11
  • 1
  • 2
  • Possible duplicate of http://stackoverflow.com/questions/346045/jquery-jcrop-how-to-set-a-fixed-size-selection-area – agriboz Feb 14 '13 at 11:19
  • It's really easy, see this answer I just posted... http://stackoverflow.com/a/16688696/2152144 – WalterEgo May 22 '13 at 09:56

1 Answers1

3

Use this code

    jQuery(document).ready(function() {
    jQuery('#imgCrop').Jcrop({
        aspectRatio: 1,
        setSelect:   [50, 0, 300,300],
        allowResize: false,
        allowSelect: false,
        onSelect: storeCoords
        });
    });

    function storeCoords(c) {
        jQuery('#X').val(c.x);
        jQuery('#Y').val(c.y);
        jQuery('#W').val(c.w);
        jQuery('#H').val(c.h);
    };
Hafeez
  • 31
  • 2