Rotating Image to 90 Degree and Saving it to page using System.Drawing

In this blog we are going to see, How to Rotate image to 90 degree and save to the web page.

Below shown only for 90 degree.

 

 

public void RotateFlipTypeImage()

        {

            //Gets image from the path.

            Image img = Image.FromFile(Server.MapPath("scenary.jpg"));

 

            //Rotate to 90 degree.

            img.RotateFlip(RotateFlipType.Rotate90FlipNone);

 

            //Get the current response

            HttpResponse response = GetHttpResponse();

 

            //Saves image to the Page in the PNG format

            img.Save(response.OutputStream, ImageFormat.Png);

        }

Thanks for reading this article. Have a nice day.