图像调整asp.net mvc应用程序的大小

Sag*_*gar 2 c# asp.net-mvc file-io file

POST EDITED添加了链接

在asp.net mvc中阅读关于图像调整大小[here] [1]的非常好的帖子.

http://dotnetslackers.com/articles/aspnet/Testing-Inbound-Routes.aspx

我需要这个逻辑来处理在cdn中上传的图像.例如我已经在cdn中上传了一个图像,现在我想从我的控制器中取出它并调整它的大小.此外,图像不应保存在我的服务器中因为它消耗宝贵的资源并不是一个好主意.图像必须从CDN读取并重新调整大小而不在本地保存在服务器中.我们如何使用上面提到的方法实现这一点.

谢谢,S.

AnY*_*Yun 9

如果您使用ASP.Net MVC3,您可以尝试新的帮助程序 - WebImage.

这是我的测试代码.

    public ActionResult GetImg(float rate)
    {
        WebClient client = new WebClient();
        byte[] imgContent = client.DownloadData("ImgUrl");
        WebImage img = new WebImage(imgContent);
        img.Resize((int)(img.Width * rate), (int)(img.Height * rate));
        img.Write();

        return null;
    }
Run Code Online (Sandbox Code Playgroud)