Rotate an image
HowToRotateAnImage.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
String path = Server.MapPath("~/Image/bird.jpg");
System.Drawing.Image img = System.Drawing.Image.FromFile(path);
img.RotateFlip(RotateFlipType.Rotate180FlipNone);
img.Save(path);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to rotate an image in asp.net programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DodgerBlue; font-style:italic;">
How to rotate an image in asp.net programmatically
</h2>
<hr width="550" align="left" color="DeepSkyBlue" />
<asp:Image
ID="Image1"
runat="server"
ImageUrl="~/Image/bird.jpg"
Height="250"
BorderStyle="Dotted"
BorderColor="SeaGreen"
BorderWidth="2"
/>
<br />
<asp:Button
ID="Button1"
runat="server"
OnClick="Button1_Click"
Text="Rotate Image: Rotate90FlipY"
Height="45"
Font-Bold="true"
ForeColor="DodgerBlue"
/>
</div>
</form>
</body>
</html>