Search code examples
c#asp.netsystem.drawingsystem.drawing.imaging

How to draw text onto a jpg and resave it using system.drawing in c#


Anyone have good example of how to write text onto a jpg image and resave it using System.Drawing in .NET?


Solution

  • Yes you can do it fairly easily...

    Bitmap bmp = new Bitmap("C:\\test.jpg");
    Graphics gra = Graphics.FromImage(bmp);
    string text = "Hello\nWorld";
    
    gra.DrawString(text, new Font("Verdana", 24), Brushes.Black, new PointF(0, 0));
    bmp.Save("C:\\test_out.jpg");