【发布时间】:2015-11-10 09:12:20
【问题描述】:
从 http 服务器获取图像。将图像大小调整为缩略图,并以不同的名称“thumb”+ imgName 保存回同一文件夹。 除了再次保存到服务器之外,这一切都有效。我尝试保存到本地并且它可以工作所以服务器是问题
Image fullsizeImage = Image.FromStream(new MemoryStream(new WebClient().DownloadData(ResolveUrl(ConfigurationManager.AppSettings["ImagesFolder"] + exportedFileName))));
Image thumbImage = fullsizeImage.GetThumbnailImage(newWidth, newHeight, null, IntPtr.Zero);
thumbImage.Save(Server.MapPath(ResolveUrl(ConfigurationManager.AppSettings["ImagesFolder"] + "thumb_" + exportedFileName)));
这不允许我将 thumbImage.Save() 返回到外部服务器 http 它标记为 'http:/localhost:61318/Uploads/thumb_6086Jellyfish.jpg' is not a valid virtual path.
所以我需要先将它传递给内存流??我试过了
string destinationFileName = ResolveUrl(ConfigurationManager.AppSettings["ImagesFolder"] + "thumb_" + exportedFileName);
System.IO.FileStream fs = System.IO.File.Open(destinationFileName, FileMode.Create);
thumbImage.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
fs.Close();
//BUT THIS FLAGGED AS - uri formats are not supported
所以我需要先创建内存吗?然后将图像保存到该路径...有什么想法吗?谢谢
【问题讨论】:
标签: c# asp.net-mvc-3