首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EPiServer不起作用的ImageProcessor

EPiServer不起作用的ImageProcessor
EN

Stack Overflow用户
提问于 2017-08-11 18:00:41
回答 1查看 466关注 0票数 1

我正在尝试使用ImageProcessor配置EPiServer 9站点,但无法使其正常工作。

我已经安装了以下nuget包:

代码语言:javascript
复制
ImageProcessor
ImageProcessor.Web
ImageProcessor.Web.Config

使用默认配置时,不会发生任何事情。在config/imageprocessor/security.config中使用以下自定义配置...

代码语言:javascript
复制
<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正在尝试调整我的图像的大小,但我得到了下面的错误...

代码语言:javascript
复制
[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

有没有人对我如何让它工作有什么建议?图像在没有宽度参数的情况下显示为正常:

http://site.local/globalassets/sample_image.jpg

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-13 03:31:01

在我使用EPiServer和ImageProcessor的项目中,我总是必须创建自己的IImageService。

如下所示:

https://gist.github.com/andreas-cloudnine/34dc468205a230f0579585db17aa1593

使用的ImageFile是项目中从EPiServer.Core.ImageData继承的媒体类型。

然后你也必须在web.config中使用它,只需将整个部分替换为以下配置:

代码语言:javascript
复制
<security>
  <services>
    <service name="EPiServerImageService" type="YourSite.EPiServerImageService, YourSite" />
</services>
</security>
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45632371

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档