This project is read-only.

Image Transformations

Image transformations are available trough services implementing OpenWaves.ImageTransformations.IImageTransformationService. The default implementation of the service (GdiImageTransformationService) uses System.Drawing namespace to transform input images. An instance of the service can be created manually (new GdiImageTransformationService()) or resolved using ServiceLocator or another dependency resolution strategy.

The interface has a single method:

public interface IImageTransformationService
    void TransformImage(Stream input, Stream output, ImageFormat outputFormat, IImageTransformation transformation);

ImageFormat enumeration determines the format of the image written to the output stream. Currently supported are Jpeg and Png.


IImageTransformation is currently implemented by a set of classes from OpenWaves.ImageTransformation namespace. All transformations can be serialized to string using ToString() method and later deserialized using ImageTransformation.Parse() method.

ScaleToFitTransformation - resizes an image so it fits specified rectangle (width/height) without clipping. For example when fitting into a square, landscape images will be sized so their width matches the width of the square, while portrait images will be sized so their height matches the height of the square. This is the most often used transformation (galleries, thumbnails, user pictures, or whenever you want to avoid clipping the image).

ScaleDownToFitTransformation - same as the above but will only resize an image if it is larger then specified rectangle (width/height). This is for example useful if you want to scale images for display on mobile device, where any image wider then the width of the screen gets scaled down, but the ones that fit the display are not transformed.

ScaleToFillTransformation - resizes an image so it fills the whole rectangle (width/height). Ultimately the image is scaled so it is large enough to cover the target area and centrally cropped to match the specified dimensions. Useful when a graphics design assumes that the picture covers the whole region of a page.



Usage examples

The following code shows how to scale "input.jpg" using ScaleToFit transformation, so it fits 100x100 rectangle. The result is written to "output.jpg".

using OpenWaves;
using OpenWaves.ImageTransformations;


var service = ServiceLocator.Resolve<IImageTransformationService>();

using (var input = File.OpenRead(@"input.jpg"))
using (var output = File.Create(@"output.jpg"))
    service.TransformImage(input, output, ImageFormat.Jpeg, new ScaleToFitTransformation(100, 100));

Windows Server 2012 Server Core mode

To use OW Image Transformations, WindowsCodecsExt.dll is required. Windows 2012 in Server Core mode DOES NOT have this dll installed in neither System32 nor SysWOW64 directory. Fortunately it can be found on the machine and copied to following localizations:
%system root%\System32\WindowsCodecsExt.dll -64bit dll version
%system root%\SysWOW64\WindowsCodecsExt.dll - 32bit dll version

Last edited Sep 20, 2013 at 2:15 PM by sparr0w, version 5


mgrzyb Feb 20, 2014 at 3:25 PM 
It is not supported as of now in the packages we provided, but I have done an integration with EPi7.5 yesterday and it is really easy. Just use OpenWaves.ImageTransformations.Web and implement your own IVirtualPathFileProvider that works agains ContentRepository instead of VPP. I'll try to update the source code with what I did.

cillen Feb 18, 2014 at 12:39 PM 
Hi again.
Will there be any updates for the 7.5 cms?

cillen Oct 7, 2013 at 1:25 PM 
Does the Image Transformations work in 7cms?