Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
JimBobSquarePants edited this page Dec 2, 2014 · 7 revisions

Welcome to the ImageProcessor wiki!

Here you will find more in depth documentation on how to use ImageProcessor and ImageProcessor.Web

Extending ImageProcessor

Writing your own processor

Create a project, for instance ImageProcessor.Plugins.MyProcessor Create a new class inheriting from ImageProcessor.Processors.IGraphicsProcessor

public class MyProcessor : IGraphicsProcessor
{
    public dynamic DynamicParameter { get; set; }

    public Dictionary<string, string> Settings { get; set; }

    public Image ProcessImage(ImageFactory factory)
    {
        Image processedImage = DoMyThing(factory.Image);
        return processedImage;
    }
}

Using your shiny new processor

Create an extension class. Your extension should be based on the following structure:

public static class ImageFactoryExtensions
{
    public static ImageFactory ProcessWithMyFilter(this ImageFactory factory, int myParameter)
    {
        if (factory.ShouldProcess)
        {
            // TODO: Sanitize the input.

            MyProcessor processor = new MyProcessor { DynamicParameter = myParameter };
            factory.CurrentImageFormat.ApplyProcessor(processor.ProcessImage, factory);
        }

        return factory;
    }
}