Adding Copyright Text to Images Image Magick and C#

Posted by craig Sunday, April 26, 2009 1:21:29 PM

 

I have looked around quite a bit for an easy way of adding copyright text into images for the various websites I have made.   I looked into ImageMagick, which seems to be the most powerful and flexible commandline tool available for doing this, however here is a very simple c# snippet for accomplishing the same result.

Bitmap bmp= new Bitmap("myimage.jpg");
  Graphics g=Graphics.FromImage(bmp);
  g.SmoothingMode = SmoothingMode.AntiAlias ;
  g.DrawString("copyright kisomnu",  new Font("verdana",12),SystemBrushes.WindowText, 1, 1);
  Response.ContentType="image/jpeg";
  bmp.Save( ... )

 

The main advantage of imageMagick is the powerful set of options to embed the text,  it is harder to achieve this in c#, the main drawback is that if the rest of our code is in c#, we need to make an external call and we furthermore generate a dependency on anexternal tool.  This can be problematic especially when we frequently upload galleries.

  Another advantage is that imagemagick can not be run on the server side in a web application (in most cases we won't have permission for this, unless we are hosting ourselves and can grant the required permissions.)

Copyright 2009 AnyTime

Way to use the interent to help people solve problems!

Thursday, July 28, 2011 3:48:53 PM Cactus
Way to use the interent to help people solve problems!

Way to use the interent to help people solve problems!

Thursday, July 28, 2011 3:47:25 PM Cactus
Way to use the interent to help people solve problems!

Way to use the interent to help people solve problems!

Thursday, July 28, 2011 3:45:58 PM Cactus
Way to use the interent to help people solve problems!