Friday, June 1, 2012

Crop Image asp.net


Just go to this link: http://webcropimage.codeplex.com/
or here is sample code:
or here is sample code:

if (addimage.HasFile)
        {

            filepath = "~/userimages/" + Profile.UserName + "/" + "1" + Convert.ToString(DateTime.Now.GetHashCode()) + addimage.FileName;
            addimage.SaveAs(MapPath(filepath));
            System.Drawing.Image userimage = System.Drawing.Image.FromFile(MapPath(filepath));
            string thumbfilepath = "~/userimages/" + Profile.UserName + "/" + "1small" + Convert.ToString(DateTime.Now.GetHashCode()) + addimage.FileName;
            userimage = crop(userimage,180,180);
            userimage.Save(thumbfilepath, userimage.RawFormat);

            imageclass.InsertImages(ticketid, Profile.userid, filepath, newclass.capcheck(title.Text));

        }

 Bitmap crop(System.Drawing.Image userimage, int Width, int Height)
    {
        Bitmap newimage = null;
      
            newimage = new Bitmap(userimage, Width, Height);

       return newimage;
    }

1 comment:

  1. In the below mentioned post, you can see full source code for uplaod and CROP images in ASP.NET/C# using JQUERY.

    http://tuvianblog.com/2012/05/22/how-to-crop-image-using-asp-netc-or-cropping-image-in-c-before-upload/

    ReplyDelete