Tuesday, January 9, 2018

Rotate image in asp.net

public void FlipImage(string Filename, string FileNameNew)
 {
      System.Drawing.Image img = System.Drawing.Image.FromFile(System.Web.Hosting.HostingEnvironment.MapPath("/images/") + Filename);
      //Rotate the image in memory
      img.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipNone);
      System.IO.File.Delete(System.Web.Hosting.HostingEnvironment.MapPath("/images/" + FileNameNew));
      //save the image out to the file
      img.Save(System.Web.Hosting.HostingEnvironment.MapPath("/images/" + FileNameNew));
      //release image file
      img.Dispose();
 }

No comments: