ImageResizing.Net WCF背后 [英] ImageResizing.Net behind WCF

查看:180
本文介绍了ImageResizing.Net WCF背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在评估拿琼斯惊人的影像库和插件对于一些图像处理服务我公司正在建设在Azure上。获取许可证之前,我们充分测试它们以确保它们适合在我们的场景中。请你帮个忙,并检查出来这里

I've been evaluating Nathanael Jones amazing imaging library and plugins for some image processing services my company is building on Azure. Before acquiring a license we are testing them fully to ensure they fit in within our scenario. Do yourself a favor and check them out Here.

我在ASP.NET MVC Web应用程序使用它们时具有插件巨大的成功。我使用,我张贴到从UI一个控制器内的图像服务器功能。裁剪,缩放和简单/高级过滤器按照预期工作。

I'm having great success with the plugins when using them in an ASP.NET MVC web application. I'm using the Image Server functionality within a Controller that I post to from the UI. Cropping, Resizing and Simple/Advanced filters are working as expected.

我遇到的问题是,当我提出这个功能WCF服务作为应用程序中的类库。裁剪和调整工作完全符合预期,但所有的过滤指令(亮度,对比度,深褐色等)要么被忽略或静默失败。这里是图像处理code:

The problems I am having is when I move this functionality to a WCF service as a class library within that application. The cropping and resizing work exactly as expected, however all the filtering instructions (brightness, contrast, sepia, etc...) are either being ignored or fail silently. Here is the image processing code:

var instructions = new ImageResizer.Instructions();

//All of these instructions work
instructions.Width = 300;
instructions.Height = 300;
instructions.Mode = ImageResizer.FitMode.Crop;
instructions.OutputFormat = ImageResizer.OutputFormat.Jpeg;
instructions.JpegQuality = 90;  
double[] cropCoordinates = {0,100,0,100};
instructions.CropRectangle = cropCoordinates;       
instructions.Mode = ImageResizer.FitMode.Crop;

//These instructions are ignored, or fail silently
instructions.Invert = true;
instructions.Saturation = -1;
instructions.Sepia = true;

var imageJob = new ImageResizer.ImageJob();

imageJob.Instructions  = instructions;
imageJob.Source = bmpSource;
imageJob.Dest = typeof(Bitmap);

imageJob.Build(); 

我重复我的MVC应用程序用于正在使用ImageResizing包(从的NuGet)类库的App.Config中的web.config设置。

I've duplicated the Web.Config settings that my MVC application used to the App.Config of the class library that is using the ImageResizing packages (from Nuget).

<configuration>
    <configSections>
        <section name="resizer" type="ImageResizer.ResizerSection" requirePermission="false" />
    </configSections>

    <resizer>
        <plugins>
            <add name="SimpleFilters" />
            <add name="AdvancedFilters" />
        </plugins>
    </resizer>

</configuration>

和只是要确定,我一直在使用语句的主要图书馆以及为插件还包括:

And just to be sure, I've also included using statements for the main library as well as for the plugins:

using ImageResizer;
using ImageResizer.Plugins.AdvancedFilters;
using ImageResizer.Plugins.SimpleFilters;

正如我所说,完全当移动到一个类库与WCF服务,但该过滤器默默地失败的裁剪和调整工作。图像被裁剪和尺寸的指示,但在过滤器不施加到图像。我试过上安装库(甚至包括我的解决方案中的每一个项目的包)几种变化。

As I mentioned, the cropping and resizing work perfectly when moved to a class library with a WCF service, but the filters are failing silently. The images are cropped and sized as instructed, but the filters are not applied to the images. I've tried several variations on installing the libraries (even including the packages on every project within my solution).

难道事实证明我的WCF服务托管为端点的net.tcp?我应该考虑更新我的架构有通过Web API驱动成像服务,WCF服务岗位来?

Could the fact that my WCF service is hosted as a NET.TCP Endpoint? Should I consider updating my architecture to have the imaging services powered via a Web API that the WCF service posts to?

更新

我绕过的Web.Config / App.Config中在code,像这样安装插件:

I'm bypassing Web.Config/App.Config by installing plugins in code like so:

ImageResizer.Configuration.Config.Current.Plugins.Install(new ImageResizer.Plugins.SimpleFilters.SimpleFilters());
ImageResizer.Configuration.Config.Current.Plugins.Install(new ImageResizer.Plugins.AdvancedFilters.AdvancedFilters());

我验证过的插件,现在中加载:

I've verified that plugins are now loaded within:

ImageResizer.Configuration.Config.Current.Plugins

我现在得到以下错误时的 imageJob.Build(); 被称为:

无法加载文件或程序集AForge.Imaging,版本= 2.2.5.0,文化=中性公钥= ba8ddea9676ca48b'或它的一个依赖。该系统找不到指定的文件。

Could not load file or assembly 'AForge.Imaging, Version=2.2.5.0, Culture=neutral, PublicKeyToken=ba8ddea9676ca48b' or one of its dependencies. The system cannot find the file specified.

希望这与配置的另一个问题,我已经添加以下​​using语句到类的使用ImageResizer顶部:

Hoping this was another issue with configuration I've added the following using statements to the top of the class that uses ImageResizer:

using AForge;
using AForge.Imaging;
using AForge.Imaging.Filters;
using AForge.Imaging.ColorReduction;
using AForge.Imaging.ComplexFilters;
using AForge.Imaging.Textures;

配置问题都解决了,但我仍然得到同样的错误了AForge库。已经开设了一个新问题,为这一特定问题<一href=\"http://stackoverflow.com/questions/29569544/configuring-imageresizing-net-programatically\">Here

推荐答案

我怀疑的配置没有被加载。您可以通过调试和检查 ImageResizer.Configuration.Config.Current 实例访问诊断页面?

I suspect that the configuration is not being loaded. Can you access the diagnostics page by debugging and inspecting the ImageResizer.Configuration.Config.Current instance?

您可能会考虑code配置软件 - 创建一个新的配置实例,并在其上​​安装插件,然后使用该为每个图像的工作。

You might consider configuring the software by code - creating a new Config instance and installing plugins on it, then using that for each image job.

总体而言,我强烈建议你使用它作为一个HttpModule,它的目的的方式 - 特别是如果你想levergage磁盘缓存

Overall, I would definitely suggest using it as an HttpModule, the way it was intended - particularly if you want to levergage disk caching.

这篇关于ImageResizing.Net WCF背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆