Search code examples
c#asp.netimage-resizingimageresizer

Configuring ImageResizing.Net Programmatically


I'm using ImageResizing.Net within a class library as part of a back-end which requires 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 loaded within:

ImageResizer.Configuration.Config.Current.Plugins

I'm getting the following error when imageJob.Build(); is called:

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.

Hoping this could be solved by referencing the libraries directly 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;

Am still getting the same error. I've verified that the AForge references exist in my project, are the correct version and have "Copy Local" set to "True". These references were part of the dependencies that were automatically installed with the Nuget Packages for ImageResizing & the associated plugins.

UPDATE

I've decided to move the image processing over to a web api since the library was not designed for this scenario. This is called out by the author of the library in the comments of this S.O. question . I will mark this as the answer.


Solution

  • I've decided to move the image processing over to a web api since the library was not designed for this scenario. This is called out by the author of the library in the comments of this S.O. question