How to create watermark image at runtime in c#? I dont want any unnecessary codes, i want easy, clear and short block of code if possible.

Thanks in advance.

Recommended Answers

It's very simple. Follow the article, it's dead on and works perfectly.

http://www.codeproject.com/KB/aspnet/httpImageHandler.aspx

Jump to Post

All 5 Replies

I like simplicity :
protected void Page_Load(object sender, EventArgs e)
{

string s = Server.MapPath("original.jpg");
string s2 = Server.MapPath("ikon.gif");

System.Drawing.Image original= Bitmap.FromFile(s);
Graphics gra = Graphics.FromImage(original);
Bitmap logo = new Bitmap(s2);
gra.DrawImage(logo, new Point(70, 70));

Response.ContentType = "image/JPEG";
big.Save(Response.OutputStream, ImageFormat.Jpeg);

}

commented: gr8 mind :). Good Luck. +1

Hey serk,
do you know what the performance costs are of running watermarking at runtime compared to saving the image, and just displaying the image?

I dont even care man :) we cache the images in the hard drive, the image loader checks if image exists, if not, it creates. So it works only one time for one image for resizing and marking issues. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.