我正在使用 asp.net mvc 4 在我的服务器上上传图像。我正在使用WebImage
类在上传之前调整我的图像大小。
但我现在确定为什么我的图像文件在上传后变大了,这不应该发生,因为我在上传之前将原始图像的大小调整为更小的尺寸。
这是我的上传代码:
[HttpPost]
public ActionResult FlatImageOne(HttpPostedFileBase file, int getFlId)
{
if (file != null && file.ContentLength > 0)
{
string picName = getFlId.ToString() + "-0";
WebImage img = new WebImage(file.InputStream);
string picExt = Path.GetExtension(file.FileName);
if (picExt == ".jpg" || picExt == ".gif" || picExt == ".jpeg" || picExt == ".png")
{
picExt = "PNG";
string path = System.IO.Path.Combine(Server.MapPath("~/Images/Flats/"), picName);
var img_resized = img.Resize(721, 482, false, false);
img_resized.Save(path, picExt);
return RedirectToAction("FlatImageOne", new { FlId = getFlId });
}
else
{
return RedirectToAction("FlatImageOne", new { FlId = getFlId });
}
}
else
{
return RedirectToAction("FlatImageOne", new { FlId = getFlId });
}
}
我该如何解决这个问题?