Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/369d04b4bf5af7d760d4e3987fe3e86f to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/369d04b4bf5af7d760d4e3987fe3e86f to your computer and use it in GitHub Desktop.
Write Text on JPG Image in .NET–STEP-by-STEP Guide
// Write Text on JPG Image in .NET-STEP-by-STEP Guide
// Read the full guide here: https://blog.aspose.com/drawing/write-text-on-jpg-image-in-dotnetstep-by-step-guide/
using System;
using Aspose.Drawing;
using Aspose.Drawing.Imaging;
using Aspose.Drawing.Drawing2D;
using Aspose.Drawing.Fonts;
using Aspose.Drawing.Brushes;
using Aspose.Drawing.Colors;
class Program
{
static void Main()
{
// Load the JPG image
using (Image image = Image.Load("input.jpg"))
{
// Create a Graphics object for drawing
using (Graphics graphics = new Graphics(image))
{
// Define the font (Arial, 36pt, bold)
Font font = new Font("Arial", 36, FontStyle.Bold);
// Define the brush (red color)
SolidBrush brush = new SolidBrush(Color.Red);
// Position where the text will be drawn
PointF location = new PointF(50, 50);
// Draw the text onto the image
graphics.DrawString("Hello, Aspose!", font, brush, location);
}
// Save the edited image as a new JPG file
image.Save("output.jpg", ImageFormat.Jpeg);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment