I have the following code to crop the image :
$.ajax({
type: "POST",
url: root("CropController/CropImage"),
data: {
imagePath: imagesrc,
cropPointX: parseInt(PointX),
cropPointY: parseInt(PointY),
imageCropWidth: parseInt(CropWidth),
imageCropHeight: parseInt(CropHeight)
}
}).done(function (dt) {
alert(dt.photo);
});
And the controller code is :
public JsonResult CropImage(string imagePath, int? cropPointX, int? cropPointY, int? imageCropWidth, int? imageCropHeight)
{
string output = imagePath.Substring(imagePath.IndexOf(',') + 1);
byte[] imageBytes = Convert.FromBase64String(output);
//croppedImage will have the cropped part of the image.
byte[] croppedImage = ImageCroping.CropImage(imageBytes, cropPointX.Value, cropPointY.Value, imageCropWidth.Value, imageCropHeight.Value);
string photo = "data:image/jpeg;base64," + Convert.ToBase64String(croppedImage);
return Json(new { photoPath = photo }, JsonRequestBehavior.AllowGet);
}
If the cropping area is small then the alert in done function will be called but it throws the error when the cropping area is large and the done function is not fired. Can anyone please help me with this. Thanks in advance