C# - 使用ImageResizer调整图像大小和裁剪图像

时间:2016-01-03 08:17:40

标签: c# imageresizer

代码

ResizeSettings resizeCropSettings = new ResizeSettings("width=100&height=150&format=jpg&crop=auto");

         string fileName = ImageBuilder.Current.Build(file, newFile, resizeCropSettings, false, true);

并且消息显示使用:

  

.Build(新的ImageJob(source,dest,settings,disposeSource,addFileExtention))。而不是FinalPath。

任何人都可以解释这是什么意思?请举个例子。

2 个答案:

答案 0 :(得分:0)

消息已经非常明确,这意味着您需要替换

...Build(file, newFile, resizeCropSettings, false, true);

var lImageJob = new ImageJob(...);

...Build(lImageJob);

答案 1 :(得分:0)

见这里:ImageResizer 'Use .Build(new Image Job(source, dest, settings, dispose Source, add FileExtension)).Final Path instead'

检查您正在使用的版本。

替换

ImageBuilder.Current.Build(file, filePath, new ResizeSettings(versions[suffix]), false, true); 

ImageBuilder.Current.Build(new ImageJob(file,filePath, new Instructions(versions[suffix]),false,true))

如果

,您将收到评论中描述的错误

原因

You didn’t install the assembly specified in the error.
Your DLL depend on other DLL’s to get its job done and if you didn’t copy or install those too, you’d indeed get this error message.
Or you have installed an older version of the assembly.
This error occurs often when we use C# HelperClass to support the orchestrations, but can occur in other situations.

Make sure that you have the last version of the assembly installed.

Rebuild the solution.
Deploy the correct solution.