ASP.NET Resize images proportionately
using System;using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO.Compression;
using System.Drawing.Drawing2D;
public partial class ImageResize : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string ImageSavePath = "E:\\jj1.jpg";
string BasePath = Server.MapPath(".");
Bitmap Img, ImgTemp;
ImgTemp = new Bitmap("E:\\Retreat.jpg");
int imgHeight = ImgTemp.Height;
int imgWidht = ImgTemp.Width;
Img = new Bitmap(ImgTemp,imgWidht*40/100, imgHeight*30/100);
Img.Save(ImageSavePath, ImageFormat.Jpeg);
ImgTemp.Dispose();
Img.Dispose();
//Graphics Graph;
//Graph = Graphics.FromImage(Img);
//Graph.DrawImage(Img, 100, 100);
}
}
No comments:
Post a Comment