我正在使用以下代码来调整和保存图像。请让我摆脱这个错误。我只在我的实时服务器上收到此错误,而它在本地主机上工作。
public void ResizeImage(Int32 height, Int32 width, Stream fromStream, String filename)
{
var image = System.Drawing.Image.FromStream(fromStream);
var newWidth = width;
var newHeight = height;
var thumbnailBitmap = new Bitmap(newWidth, newHeight);
var thumbnailGraph = Graphics.FromImage(thumbnailBitmap);
thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality;
thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
thumbnailGraph.DrawImage(image, imageRectangle);
//thumbnailBitmap.Save(toStream, image.RawFormat);
String path = Server.MapPath("~/signatures/" + filename);
thumbnailBitmap.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);
thumbnailGraph.Dispose();
thumbnailBitmap.Dispose();
image.Dispose();
}