我正在尝试使用ImageProcessor配置 EPiServer 9 站点,但无法使其工作。
我已经安装了以下 nuget 软件包:
ImageProcessor
ImageProcessor.Web
ImageProcessor.Web.Config
使用默认配置没有任何反应。使用 config/imageprocessor/security.config 中的以下自定义配置...
<security>
<services>
<service name="CloudImageService" type="ImageProcessor.Web.Services.CloudImageService, ImageProcessor.Web">
<settings>
<setting key="MaxBytes" value="8194304" />
<setting key="Timeout" value="30000" />
<setting key="Host" value="http://site.local/globalassets/"/>
</settings>
</service>
<service prefix="remote.axd" name="RemoteImageService" type="ImageProcessor.Web.Services.RemoteImageService, ImageProcessor.Web">
<settings>
<setting key="MaxBytes" value="4194304" />
<setting key="Timeout" value="3000" />
<setting key="Protocol" value="http" />
</settings>
<whitelist>
</whitelist>
</service>
</services>
</security>
...似乎 ImageProcessor 正在尝试调整我的图像大小,但出现以下错误...
[ImageFormatException: Input stream is not a supported format.]
ImageProcessor.ImageFactory.Load(Stream stream) +523
ImageProcessor.Web.HttpModules.<ProcessImageAsync>d__34.MoveNext() +3308
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) +64
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +162
...当尝试将图像大小调整为 200px 宽度时:
http://site.local/globalassets/sample_image.jpg?width=200
任何人都对我如何使其工作有任何建议?图像在没有宽度参数的情况下显示为正常:
在我将 EPiServer 与 ImageProcessor 一起使用的项目中,我总是不得不创建自己的 IImageService。
像这样的东西:
https://gist.github.com/andreas-cloudnine/34dc468205a230f0579585db17aa1593
使用的 ImageFile 是项目中从 EPiServer.Core.ImageData 继承的媒体类型。
然后你也必须在 web.config 中使用它,只需用这个配置替换整个部分:
<security>
<services>
<service name="EPiServerImageService" type="YourSite.EPiServerImageService, YourSite" />
</services>
</security>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句