Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A C# image enhancement filters library

0.00/5 (No votes)
11 May 2007 5  
A set of filters to modify and style your images and photos

Library Home Page

Screenshot - box_colors2.png

Introduction

This project started from a need. A need to have a simple image/photo .NET filters functionality to style and enhance pictures to be displayed on the web (or any other place for that matter). True, there are some filter libraries scattered around the web for doing stuff like a WaterMark or a GrayScale or even a collection of those (ImageMagick). In most cases they are very basic or unhelpful for styling images. Furthermore, the .NET System.Drawing.* namespace doesn't provide any basic or sophisticated capabilities. For example, there isn't a proper rotate or resize functionality. So the goal was to collect all of the nice .NET filters that are out there into a single package and to extend it by providing more useful and styled filters.

Implementation

From the need that was described above I've created YAEL, which stands for: Yet Another Image Enhancement Library.

It is just a framework and filter classes. No UI (for now). The framework is very basic and simple so that extensions can easily be developed.

There is a basic IFilter interface and a BasicFilter abstract class. All of the filters derive from the BasicFilter class.

Current library filters consist of

  • Resize
  • Rotate
  • Grayscale
  • Rounded Corners
  • Boxing
  • Drop Shadow
  • Polaroid frame
  • Text and wartermark captions
  • Image watermark
  • Floor Reflection
  • FishEye
  • Skew
  • And more to come...

Here are some Samples:

Screenshot - grayScale_brighter.png

Screenshot - rotate_minus_30.png

Screenshot - rounded_35.png

Screenshot - box_colors2.png

Screenshot - dropShadow.png

Screenshot - dropShadow.png

Screenshot - text_water_middle_left.png

Screenshot - image_watermark_pacman.png

Screenshot - image_fisheye_default.png

Screenshot - image_floor_reflection.png

Screenshot - image_skew_plain.png

Usage

Usage is very straightforward. All you have to do is reference the library assemblies, load up an image, initialize a filter, execute the filter, and save back the transformed image.

Here is a sample:

static void Main(string[] args)
{
    Image myImg = Bitmap.FromFile("cat.jpg");
    Image transformedImage;
    ZRLabs.Yael.BasicFilters.TextWatermarkFilter watermark = new 
        TextWatermarkFilter();
    ZRLabs.Yael.BasicFilters.BoxFilter box = new BoxFilter();
    ZRLabs.Yael.BasicFilters.BlackAndWhiteFilter blackAndWhite = new 
        BlackAndWhiteFilter();

    //A text watermark example

    watermark.Caption = "Test";
    watermark.AutomaticTextSize = true;
    transformedImage = watermark.ExecuteFilter(myImg);
    transformedImage.Save("cat_watermark.png", 
        System.Drawing.Imaging.ImageFormat.Png);

    //A boxing example

    transformedImage = box.ExecuteFilter(myImg);
    transformedImage.Save("cat_box.png", 
        System.Drawing.Imaging.ImageFormat.Png);

    //A grayscale example

    transformedImage = blackAndWhite.ExecuteFilter(myImg);
    transformedImage.Save("cat_blackAndWhite.png", 
        System.Drawing.Imaging.ImageFormat.Png);
}

Update

  • 15-Dev-2006
    • V1.0.3.0 Released
      • Added the Fisheye, FloorReflection and Skew filters.
      • Added a pipeline helper class for easy and fluent transformations.
  • 28-Nov-2006
    • Added the ability to use images on the BoxFilter on the top and side panels.
      Check out the samples page for examples.
  • 27-Nov-2006
    • Added a KeepAspectRatio property to the ResizeFilter
  • 23-Nov-2006
    • Added an image watermark filter
    • Changed the license to LGPL

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here