Click here to Skip to main content
6,305,776 members and growing! (18,006 online)
Email Password   helpLost your password?
Multimedia » General Graphics » Graphics     Intermediate

Watermark Creator

By Big D

A tool which overlays a watermark and/or copyright statement on the bottom of an image.
C#, Windows, .NET 1.0, .NET 1.1, .NET 2.0, GDI+, WinForms, VS.NET2003, VS2005, Dev
Posted:15 Jun 2005
Updated:20 Jun 2005
Views:47,033
Bookmarked:66 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
16 votes for this article.
Popularity: 5.09 Rating: 4.23 out of 5
1 vote, 6.3%
1

2
3 votes, 18.8%
3
3 votes, 18.8%
4
9 votes, 56.3%
5

Mark my Image Tool....

Introduction

I wanted to watermark a few sunset images taken by me, before posting it to internet. After searching for an hour or so, I couldn't find any freeware tool. All were shareware, means you have to buy, #$#$!@##!#@#@. I decided to make a tool on my own, many thanks to Joel Neubeck's article in CodeProject. Using his article, I just tried to create a proper user friendly GUI tool to mark images with copyright note, also optionally with your company logo.

You can call the tool Watermark Creator, Watermark tool or anything. I named it as MarkMyImage.

Sample watermarked image

The above image is taken from the internet, copyright to respected owner.

Using the code

You can download the source code, and modify it according to your needs, though I feel you need not modify anything :-).

  • Before running the application do not forget to run "MarkMyImage.reg". This will create the necessary keys into your registry (to store user preference).
  • Form_Load takes values from the system registry and initializes the screen.
  • You should now point your working folder to your image folder (input folder), where your images are located.
  • You can preview all the images, and select the required ones (by default, all images be selected).
  • By default, all output files will be generated as "[filename][suffix].ext", in the same folder. By default, the suffix is "_final".
  • You can set a different output folder, this way the output file name(s) will remain same.
  • Form_Closed saves all the current settings into the registry.

Class Watermark has two constructors, with or without the watermark image.

WaterMark(string WorkingDirectory, string Copyright, Image ImgWatermark);
WaterMark(string WorkingDirectory, string Copyright);

According to user choice (watermark image preference), we will create the WaterMark object by passing the necessary parameters...

if (chkWaterMarkImage.Checked == true)
    wm = new WaterMark(txtWorkingFolder.Text, 
                       txtCopyRight.Text,picWaterMark.Image);
else
    wm = new WaterMark(txtWorkingFolder.Text,txtCopyRight.Text);

Now, a simple execution loop for all the selected files.

for(int i=0;i<lstFileList.CheckedItems.Count;i++)
{
    srcPic = txtWorkingFolder.Text + 
          lstFileList.Items[i].ToString().Substring(
          lstFileList.Items[i].ToString().LastIndexOf("\\"));
    if (chkSameOutputFolder.Checked == true)
        dstPic = srcPic.Insert(srcPic.LastIndexOf("."),txtSuffix.Text);
    else
        dstPic = txtOutputFolder.Text + "\\" + 
                 srcPic.Substring(srcPic.LastIndexOf("\\") + 1);

    wm.MarkImage(srcPic,dstPic);
    progressBar1.Increment(1);
    statusBarPanel2.Text = "Proecessing Image " + 
      srcPic.Substring(lstFileList.Items[i].ToString().LastIndexOf("\\") + 1);
    Application.DoEvents();
}

Points of Interest

  • I really wanted to put jazzzzyy text in images, something like MS� Word Art. Now, it is very well possible after a few modifications in the source code. I will try to modify the source (hope I'll get the time) so that positions of "Copyright notice" and "logo" are configurable.
  • This example also shows a simple use of the PropertyGrid control.
  • I found a very nice logic to set the default values of the PropertyGrid control. It uses PropertyInfo of System.Reflection. Take a look at the following block of code:
    PropertyInfo[] props = this.GetType().GetProperties();
    for (int i=0; i<props.Length; i++)
    {
        object[] attrs = 
          props[i].GetCustomAttributes(typeof(DefaultValueAttribute),false);
        if (attrs.Length > 0)
        {
            DefaultValueAttribute attr = (DefaultValueAttribute)attrs[0];
            props[i].SetValue(this,attr.Value,null);
        }
    }
  • get all the properties props.
  • get the custom attribute of each property attrs.
  • get DefaultValueAttribute.
  • set property value.

History

  • 21 June 2005, 1.0 - Tip release of MarkMyImage.
    • Not properly tested, please let me know if you face any error/bug.
    • Copyright notice/watermark notice and watermark logo positions are configurable.
    • Drawback 1, currently the tool supports only JPEG (*.jpg, *.jpeg) and bitmap (*.bmp) images.
  • 15 June 2005, first release of MarkMyImage.
    • Drawback 1, copyright notice/watermark notice and watermark logo positions are hard-coded, hence not configurable.
    • Drawback 2, currently the tool supports only JPEG (*.jpg, *.jpeg) and bitmap (*.bmp) images.

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

About the Author

Big D


Member
Big D(Formal Name: Deb'jyoti Das) has more than 9 yrs exp in .Net,C#,VB,C,C++,.He is also experienced with few interesting telecommunication,networking, custom protocol projects.

Currently he is working on WCF,LinQ,EDM.

Professionally he never works(or wanted to) primarily on Graphics, but Big D is interested and has a good knowledge of Application's Look N Feel, Graphics, and a bit of GDI programming.

Big D likes to create (or do some R & Ds) on interesting tools, update his websites in his free time, likes photography, specially nature and sunsets.
Occupation: Program Manager
Location: United States United States

Other popular General Graphics articles:

  • A flexible charting library for .NET
    Looking for a way to draw 2D line graphs with C#? Here's yet another charting class library with a high degree of configurability, that is also easy to use.
  • CxImage
    CxImage is a C++ class to load, save, display, transform BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K images.
  • 3D Pie Chart
    A class library for drawing 3D pie charts.
  • Really cool visual FX
    A set of classes for doing stunning visual effects, including water, plasma and fire.
  • ImageStone
    An article on a library for image manipulation.
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 15 of 15 (Total in Forum: 15) (Refresh)FirstPrevNext
GeneralMy vote of 1 Pinmemberslava_pvf4:43 18 Jun '09  
Generalexcellent tool Pinmemberrobbiegis22:25 9 Jul '08  
GeneralRe: excellent tool PinmemberBig D5:05 12 Jul '08  
Generalwatermarking images Pinmembertauras8121:48 20 Sep '07  
GeneralGraphics.DrawString Issue Pinmemberj1mcmahon14:04 3 Jan '07  
QuestionHow can I watermark anything at runtime? PinmemberNhilesh B22:43 29 Apr '06  
GeneralNice work,thanks Pinmemberkellyonlyone2:52 17 Feb '06  
GeneralRe: Nice work,thanks PinmemberBig D11:39 29 Jan '07  
Generalreally cool work PinmemberDAVE_ES6:10 14 Nov '05  
GeneralRe: really cool work PinmemberBig D18:17 6 Dec '05  
Generalreally cood work PinmemberDAVE_ES6:08 14 Nov '05  
GeneralThanks a lot for your work. PinmemberLittleTiger16:31 1 Aug '05  
GeneralRe: Thanks a lot for your work. PinmemberBig D4:16 11 Aug '05  
GeneralPrintable watermark PinmemberWilliam F2:31 29 Jun '05  
GeneralRe: Printable watermark PinmemberBig D3:03 30 Jun '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Jun 2005
Editor: Smitha Vijayan
Copyright 2005 by Big D
Everything else Copyright © CodeProject, 1999-2009
Web17 | Advertise on the Code Project