0

我下载了 Nugent ImageResizer,我正在尝试按照此页面http://imageresizing.net/docs/managed上的示例调整上传图片的大小,但我看不到将其放入 Var 或 Image 变量中,所以我可以在Path.Combine中看到它是代码

var fileName = Path.GetFileName(file.FileName);
                var changename = getid + "_" + fileName;
          ImageBuilder.Current.Build(changename, changename,
                                                       new ResizeSettings("width=130&height=130"));

            var path = Path.Combine(Server.MapPath("~/uploads/profilepic"), changename);
                file.SaveAs(path);

如何在 var 或某种类型的图像变量中获取ImageBuilder我想做的是这样的

        var resized=  ImageBuilder.Current.Build(changename, changename,
                                                       new ResizeSettings("width=130&height=130"));
var path = Path.Combine(Server.MapPath("~/uploads/profilepic"), resized);
                file.SaveAs(path);

我要做的就是将ImageBuilder放在Path.Combine中而不会出错,我们将不胜感激。

4

1 回答 1

0

ImageResizer 应该直接给出上传的文件和输出路径

ImageResizer 支持 GUID 和路径清理。切勿按原样使用上传的文件名!

var i = new ImageJob(file, 
                    "~/uploads/profilepic/<guid>_<filename:A-Za-z0-9>.<ext>", 
                     new ResizeSettings("width=130&height=130&format=jpg"));
i.CreateParentDirectory = true; //Auto-create the uploads directory.
i.Build();

var newVirtualPath = ImageResizer.Util.PathUtils.GuessVirtualPath(i.FinalPath);
于 2013-09-10T14:05:51.613 回答