【发布时间】:2014-11-15 08:36:14
【问题描述】:
我正在编写 MVC5 互联网应用程序,并且正在将图像上传到 Azure blob 存储。当用户上传图片时,我希望创建一个缩略图并将此图片保存到 blob 存储中。
我有图像的输入流,并将其用作我函数的Stream fileStream 参数。
这是我当前的代码:
public void CreateImageThumbnailFromStream(Stream fileStream, string filename, int width, int height)
{
System.Drawing.Image image = System.Drawing.Image.FromStream(fileStream);
System.Drawing.Image thumbnailImage = image.GetThumbnailImage(width, height, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
MemoryStream imageStream = new MemoryStream();
thumbnailImage.Save(imageStream, System.Drawing.Imaging.Imageformat.Jpeg);
if (imageStream.Length > 0)
{
string containerName = User.Identity.GetUserName();
CloudBlobContainer blobContainer = _blobStorageService.GetCloudBlobContainer(containerName);
CloudBlockBlob blob = blobContainer.GetBlockBlobReference(filename);
blob.UploadFromStream(imageStream);
}
}
我收到以下错误:
The type or namespace name 'Imageformat' does not exist in the namespace 'System.Drawing.Imaging' (are you missing an assembly reference?
在这行代码处:
thumbnailImage.Save(imageStream, System.Drawing.Imaging.Imageformat.Jpeg);
我参考了以下程序集:
System.Drawing (in System.Drawing.dll)
这是 MSDN 类文档:
http://msdn.microsoft.com/en-us/library/system.drawing.imaging.imageformat(v=vs.110).aspx
我可以对我的代码提供一些帮助吗?
提前致谢
【问题讨论】:
标签: image azure visual-studio-2013 asp.net-mvc-5