public static void SaveSmallImage(string photoPath, string savePath, int mWidth, int mHeight)
{
System.Drawing.Image image, aNewImage;
int newWidth, newHeight;
System.Drawing.Image.GetThumbnailImageAbort callb = null;
image = System.Drawing.Image.FromFile(System.Web.HttpContext.Current.Server.MapPath(photoPath));
newHeight = mHeight;
newWidth = mWidth;
if (mWidth == 0)
{
newWidth = image.Width / image.Height * newHeight;
}
if (mHeight == 0)
{
newHeight = image.Height / image.Width * newWidth;
}
aNewImage = image.GetThumbnailImage(newWidth, newHeight, callb, new System.IntPtr());
aNewImage.Save(System.Web.HttpContext.Current.Server.MapPath(savePath), System.Drawing.Imaging.ImageFormat.Jpeg);
}
asp.net生成缩略图
最新推荐文章于 2025-03-03 09:47:49 发布