Question

I am using JCrop in my ASP.NET C# application to crop image. by default, i want crop selection area to be set in center of the image, here is my current code, but problem is, it starts selection with 0,0 always.

            $('#img_crop').Jcrop({    //img_crop is the ID of image control
                onChange: updatePreview, // will display the selected img on change.
                onSelect: updatePreview, // will display the selected img Img_preview
                bgColor: 'black',
                bgOpacity: .6,
                //setSelect: [100, 100, 240, 240],
                setSelect:   [ ($('#img_crop').attr('width') / 2) - 70, 
                       ($('#img_crop').attr('height') / 2) - 70, 
                       ($('#img_crop').attr('width') / 2) + 70, 
                       ($('#img_crop').attr('height') / 2) + 70
                     ],
                onSelect: storeCoords, // will tell the coordinates
                aspectRatio: 1

            }
Was it helpful?

Solution

The attributes 'width' and 'height' are probably not set. I would rather use $('#img_crop').width() and $('#img_crop').height() instead, to see if that works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top