ImageProcessor.Web 4.1.0 Released!

Following yesterdays post charting the updates in the the core ImageProcessor library I'm going to take the time to chart the updates in the new 4.1.0 release of ImageProcessor.Web

New Stuff

Methods

All the new methods available to ImageProcessor are available to ImageProcessor.Web.

  • Pixelate
  • DetectEdges
  • EntropyCrop
  • Mask
  • Overlay

Syntactically they are invoked using familiar rules similar to preexisting methods.

For example.

http://your-image?detectedges=prewitt&greyscale=false

Will produce an image with a Prewitt operator applied that also retains the original image colours.

Original

enter image description here

Processed

enter image description here

Swish!

Handling Images in Instructions

Two of the new methods: Mask & Overlay accept images as parameters in part of their instruction sets. Rather than passing the entire path to the url (which would open up all sorts of security issues) you set the image name only as a parameter. These are mapped to two preconfigured locations.

  • Mask- ~/images/imageprocessor/mask/
  • Overlay - ~/images/imageprocessor/overlay/

These can both be overwritten by installing the ImageProcessor.Web.Config package from Nuget and changing the settings in the processing.config file.

Here's the two of them in action.

Mask

http://your-image??mask=mask.png&mask.position=30,30&format=png

Original

Locks on a gate

Masked

Masked image of locks on a gate

Overlay

http://your-image?overlay=monster.png&overlay.position=30,30&overlay.size=100,100&overlay.opacity=80

Original

A Grizzly bear

Overlay Applied

A Grizzly bear


Moar New Stuff

IImageService

With this version comes a new system for supplying ImageProcessor.Web images to process; IImageService.

The IImageService interface defines methods and properties which allow developers to extend ImageProcessor.Web to retrieve images from alternate locations to process. Think pulling images from from a SqlServer filestream or from another custom service.

Creating a new service simply requires implementing the interface to supply a prefix and a byte array.

The interface looks like this.

/// <summary>
///  Defines properties and methods for allowing retrieval of image from different sources.
/// </summary>
public interface IImageService
{
    /// <summary>
    /// Gets or sets the prefix for the given implementation.
    /// <remarks>
    /// This value is used as a prefix for any image requests that should use this service.
    /// </remarks>
    /// </summary>
    string Prefix { get; set; }
    /// <summary>
    /// Gets a value indicating whether the image service requests files from
    /// the locally based file system.
    /// </summary>
    bool IsFileLocalService { get; }
    /// <summary>
    /// Gets or sets any additional settings required by the service.
    /// </summary>
    Dictionary<string, string> Settings { get; set; }
    /// <summary>
    /// Gets or sets the white list of <see cref="System.Uri" />. 
    /// </summary>
    Uri[] WhiteList { get; set; }
    /// <summary>
    /// Gets a value indicating whether the current request passes sanitizing rules.
    /// </summary>
    /// <param name="path">
    /// The image path.
    /// </param>
    /// <returns>
    /// <c>True</c> if the request is valid; otherwise, <c>False</c>.
    /// </returns>
    bool IsValidRequest(string path);
    /// <summary>
    /// Gets the image using the given identifier.
    /// </summary>
    /// <param name="id">
    /// The value identifying the image to fetch.
    /// </param>
    /// <returns>
    /// The <see cref="System.Byte" /> array containing the image data.
    /// </returns>
    Task<byte[]> GetImage(object id);
}

Both the local and remote image service implement this interface. View the source code to see examples.

Extras

With this release I upped the cache to hold 100 images per folder. This now increases the theoretical cache limit to 409,600,000,000 images though I don't think anyone will be hitting that kind of limit any time soon.

There's a few performance improvements thrown in also that will make things snappier than ever.

In Summary

I'm pleased with this release and the benefits it offers. There's only a few feature I think that ImageProcessor.Web is missing (Face detection being one) so I hope you are enjoying using it as much as I do building it.

comments powered by Disqus