Click here to Skip to main content
Licence LGPL3
First Posted 18 Nov 2006
Views 93,285
Downloads 1,584
Bookmarked 142 times

A C# image enhancement filters library

By | 11 May 2007 | Article
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, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

About the Author

Roiy Zysman

Web Developer

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
AnswerRe: Doubts over its code example PinmemberRoiy Zysman5:32 21 Jul '08  
QuestionRe: Doubts over its code example PinmemberLuizItatiba7:20 21 Jul '08  
GeneralI saw your link in Samples of http://www.dotnetclan.com/zrlabs/yael/YaelMain.htm PinmemberLuizItatiba16:48 18 Jul '08  
AnswerRe: I saw your link in Samples of http://www.dotnetclan.com/zrlabs/yael/YaelMain.htm PinmemberRoiy Zysman23:51 18 Jul '08  
QuestionRe: I saw your link in Samples of http://www.dotnetclan.com/zrlabs/yael/YaelMain.htm PinmemberLuizItatiba7:04 19 Jul '08  
QuestionHow to combine several images ino one? PinmemberAndrie Kostyuk8:26 27 Jul '07  
AnswerRe: How to combine several images ino one? [modified] PinmemberRoiy Zysman19:12 6 Aug '07  
I thought of putting this kind of filter in. I'll probably add it to a future release.
But here is a sample of how to do this in the meantime.
Hope it helps
 
inputImage = @"c:\temp\cat.jpg";
outputImage = @"c:\temp\cat_out.jpg";
Bitmap bm = Bitmap.FromFile("c:\temp\back.jpg"); //Your 800x600 background image
Graphics g = Graphics.FromImage(bm);
System.Drawing.Image fore =System.Drawing.Image.FromFile(@"c:\temp\cat.jpg";);
//upper left corner starts from 0,0 -> can be changed to whatever you want
g.DrawImage(_img, 0, 0, fore.Width, fore.Width);
bm.Save(outputImage, System.Drawing.Imaging.ImageFormat.Jpeg);
 
Roiy
 
modified on Saturday, July 19, 2008 5:53 AM

GeneralRe: How to combine several images ino one? PinmemberAndrie Kostyuk4:00 7 Aug '07  
GeneralCan´t use imageWaterMark.Halign ... PinmemberLordMM23:41 10 Jun '07  
AnswerRe: Can´t use imageWaterMark.Halign ... PinmemberRoiy Zysman10:41 12 Jun '07  
QuestionImage with rounded corners and a border... Pinmemberburning snow3:35 1 Jun '07  
AnswerRe: Image with rounded corners and a border... PinmemberRoiy Zysman6:22 1 Jun '07  
GeneralRe: Image with rounded corners and a border... Pinmemberburning snow6:53 1 Jun '07  
AnswerRe: Image with rounded corners and a border... [modified] PinmemberRoiy Zysman11:13 1 Jun '07  
GeneralRe: Image with rounded corners and a border... Pinmemberburning snow9:57 3 Jun '07  
GeneralCan't compile PinmemberNice Life22:19 23 May '07  
GeneralRe: Can't compile PinmemberRoiy Zysman22:31 27 May '07  
GeneralRe: Can't compile PinmemberNice Life18:45 28 May '07  
GeneralRe: Can't compile PinmemberRoiy Zysman10:19 29 May '07  
GeneralRe: Can't compile PinmemberNice Life19:42 29 May '07  
GeneralSuggestion for new filters PinmemberCarlosMMartins22:37 14 May '07  
AnswerRe: Suggestion for new filters PinmemberRoiy Zysman10:15 17 May '07  
QuestionWhere's crop? Pinmembermmedia7:59 27 Feb '07  
AnswerRe: Where's crop? PinmemberRoiy Zysman11:23 2 Mar '07  
GeneralDeskew / Crop PinmemberRenesisX0:43 7 Dec '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120529.1 | Last Updated 11 May 2007
Article Copyright 2006 by Roiy Zysman
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid