ImageProcessingModule
The ImageProcessingModule class provides methods to perform various manipulation functions on a given image based on querystring parameters. The HttpModule is asynchronous and optimized for performance so that your website does not slow down under heavy load.
The API for ImageProcessor.Web is imperative. This means that the order in which you supply the querystring parameters is the order in which the individual processors are implemented. This allows the API to be very flexible, allowing you to combine processes in any order.
Remote Files
ImageProcessor.Web allows you to configure remote image requests from a whitelist of urls.
These commands are set in the security.config file under the
path \config\imageprocessor\
within your solution. The more precise the url, the more restrictive the whitelist.
Remote requests are given in the following format:
Caching
ImageProcessor.Web comes with caching as standard. Any processed image are asynchronously cached both in the browser and on the server for a length of your choosing. The server cache intelligently stores millions of images and silently updates itself should the original image change or the cache expire.
Cached files, by default, are stored in nested folders based on an SHA-1 representation of the full url with a small number of images in each folder. This allows for the storage of millions of images whilst ensuring that the OS does not suffer from any slowdown due to file indexing.
The caching mechanism saves massive amounts of processing power and bandwidth that help to keep your website snappy.
Events
ImageProcessingModule.ValidatingRequest
On initial examination of an image request the ImageProcessingModule will raise an
ValidatingRequest
event. This allows the developer to add their own instructions to
the ImageProcessingModule without requiring them to be present in the request URL. This is useful
for adding extra security measures to image requests or for changing the background colour of image formats that do not
support alpha transparency.
This event passes the following parameters:
- sender
-
The instance of
ImageProcessingModule
raising the event. - eventargs
-
The
ValidatingRequestEventArgs
containing the following information.- Context
- The current
HttpContext
.
- Querystring
- The querystring part of the current request.
Example Code
ImageProcessingModule.OnProcessQuerystring
As of version 4.6.0 this event has been marked obsolete.
Use ImageProcessingModule.ValidatingRequest instead
.
On initial examination of an image request the ImageProcessingModule will raise an
OnProcessQuerystring
event. This allows the developer to add their own instructions to
the ImageProcessingModule without requiring them to be present in the request URL. This is useful
for adding security watermarks to images or for changing the background colour of image formats that do not
support alpha transparency.
This event passes the following parameters:
- sender
-
The instance of
ImageProcessingModule
raising the event. - eventargs
-
The
ProcessQuerystringEventArgs
containing the following information.- RawUrl
- The raw URL of the current request.
- Querystring
- The querystring part of the current request.
Example Code
ImageProcessingModule.OnPostProcessing
On processing of a new or updated, uncached image the ImageProcessingModule will raise an awaitable
OnPostProcessing
event.
This passes the following parameters:
- sender
-
The instance of
ImageProcessingModule
raising the event. - eventargs
-
The
PostProcessingEventArgs
containing the following information.- CachedImagePath
- The absolute path to the newly cached image.