Add watermark to the saved or converted photos

Hi,
Possible to do that? If so any sample in .net? Thanks

@ariamehr

Yes, it is possible to add a watermark to saved or converted photos using Aspose.Imaging in .NET. Below is a sample code that demonstrates how to do this.

Sample Code to Add Watermark in .NET

using System;
using Aspose.Imaging;
using Aspose.Imaging.Brushes;

namespace Aspose.Imaging.Examples.CSharp.ModifyingAndConvertingImages
{
    public class AddWatermarkToImage
    {
        public static void Run()
        {
            Console.WriteLine("Running example AddWatermarkToImage");
            // Specify the path to the image file
            string dataDir = "path_to_your_image_directory/";
            
            // Load an existing image
            using (Image image = Image.Load(dataDir + "your_image.bmp"))
            {
                // Create an instance of Graphics class
                Graphics graphics = new Graphics(image);

                // Create a Font instance
                Font font = new Font("Times New Roman", 16, FontStyle.Bold);

                // Create a SolidBrush and set its properties
                SolidBrush brush = new SolidBrush();
                brush.Color = Color.Black;
                brush.Opacity = 100;

                // Draw the watermark text at a specific position
                graphics.DrawString("Your Watermark Text", font, brush, new PointF(image.Width / 2, image.Height / 2));
                
                // Save the image with the watermark
                image.Save(dataDir + "WatermarkedImage_out.bmp");
            }

            Console.WriteLine("Finished example AddWatermarkToImage");
        }
    }
}

Explanation

  1. Load the Image: The code loads an existing image from the specified directory.
  2. Create Graphics Object: A Graphics object is created to draw on the image.
  3. Define Font and Brush: A font and a solid brush are defined for the watermark text.
  4. Draw the Watermark: The watermark text is drawn at the center of the image.
  5. Save the Image: Finally, the modified image is saved with the watermark.

Make sure to replace "path_to_your_image_directory/" and "your_image.bmp" with the actual path and filename of your image.

For more examples and detailed documentation, you can refer to the Aspose.Imaging for .NET GitHub repository.

If you have any further questions or need additional examples, feel free to ask!