使用ASP.NET创建缩略图的最佳方法是什么?
发布时间:2020-12-16 00:48:03 所属栏目:asp.Net 来源:网络整理
导读:故事:用户上传要添加到照片库的图像。作为上传过程的一部分,我们需要A)将图像存储在Web服务器的硬盘驱动器上,B)将图像的缩略图存储在Web服务器的硬盘驱动器上。 这里的“最佳”定义为 相对容易实施,理解和维护 结果质量合理的缩略图 性能和高质量的缩略
故事:用户上传要添加到照片库的图像。作为上传过程的一部分,我们需要A)将图像存储在Web服务器的硬盘驱动器上,B)将图像的缩略图存储在Web服务器的硬盘驱动器上。
这里的“最佳”定义为 >相对容易实施,理解和维护 性能和高质量的缩略图是次要的。 解决方法
我想你最好的解决方案是使用.NET
Image类的
GetThumbnailImage 。
// Example in C#,should be quite alike in ASP.NET // Assuming filename as the uploaded file using ( Image bigImage = new Bitmap( filename ) ) { // Algorithm simplified for purpose of example. int height = bigImage.Height / 10; int width = bigImage.Width / 10; // Now create a thumbnail using ( Image smallImage = image.GetThumbnailImage( width,height,new Image.GetThumbnailImageAbort(Abort),IntPtr.Zero) ) { smallImage.Save("thumbnail.jpg",ImageFormat.Jpeg); } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 使用ASP.NET MVC 3和实体框架4.1代码首先在SQL CE 4.0中存储
- asp.net-mvc – 获取视图名称,其中ViewResult.ViewName为单
- ASP.NET Core中的依赖注入(3): 服务的注册与提供
- Asp.net和windows身份验证
- asp.net-mvc – 使用Ajax.ActionLink进行正确的HTTP删除问题
- asp.net – 解析美国邮政地址的免费API?
- asp.net – 数据库交互/业务逻辑在MVC中发生在哪里?
- 是否可以实现自我更新的ASP.NET Web应用程序?
- asp.net-mvc – Mvc 4脚本包和GZip
- ASP.net MVC中的Ajax帮助器
推荐文章
站长推荐
- asp.net – 使用DataContext静态变量
- asp.net-mvc-3 – ASP.NET MVC强类型HTML帮助程序
- 从ASP.NET应用程序删除目录返回到新会话
- asp.net-mvc – 在AccountController之外访问Use
- 你在.NET中最喜欢的功能是什么?
- asp.net-mvc-3 – MVC视图的命名空间问题 – Raz
- asp.net-web-api – 是否可以从消息处理程序访问
- asp.net – 用于DropDownList的MVC2 EditorTempl
- asp.net-mvc – Fluent Validation不会在第一次验
- IdentityServer4 ASP.NET核心API Angular:登录/
热点阅读