【发布时间】:2011-02-05 17:40:27
【问题描述】:
我正在使用以下方法为在线图像创建缩略图:
public static string SaveThumbnail(string imageUrl, int newWidth, int newHeight, string id)
{
string uploadImagePath = "/UploadedImages/";
Stream str = null;
HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create(imageUrl);
HttpWebResponse wRes = (HttpWebResponse)(wReq).GetResponse();
str = wRes.GetResponseStream();
using (var image = Image.FromStream(str, false, true))
{
Image thumb = image.GetThumbnailImage(newWidth, newHeight, () => false, IntPtr.Zero);
string pathAndName = Path.ChangeExtension(uploadImagePath + id, "thumb");
thumb.Save(pathAndName);
return pathAndName;
}
}
但我得到了这个错误:
说明:当前网页执行过程中出现未处理的异常
要求。请查看堆栈跟踪以获取有关错误及其位置的更多信息
起源于代码。
异常详情:
System.Runtime.InteropServices.ExternalException:GDI+ 中发生一般错误。
有什么想法吗?
【问题讨论】:
-
几天前我也遇到了这个错误。这是因为我用来保存图像的路径错误。仍然抛出 GDI+ 错误!