// Colors: Red,Blue,Purple,#006666 private static IImageProcessingContext DrawWatermark(this IImageProcessingContext context, WatermarkSettings settings) { var imgSize = context.GetCurrentSize(); // measure the text size var size = TextMeasurer.Measure(settings.Text, new RendererOptions(settings.TextFont)); //find out how much we need to scale the text to fill the space (up or down) var scalingFactor = Math.Min(imgSize.Width / size.Width, imgSize.Height / size.Height) / 3; //create a new settings.TextFont var scaledFont = new Font(settings.TextFont, scalingFactor * settings.TextFont.Size); var center = settings.Position switch { WatermarkPosition.Top => new PointF(imgSize.Width / 2, (imgSize.Height / 9)), WatermarkPosition.TopLeft => new PointF(imgSize.Width / 2, (imgSize.Height / 9)), WatermarkPosition.TopRight => new PointF(imgSize.Width / 2, (imgSize.Height / 9)), _ => new PointF(imgSize.Width / 2, imgSize.Height - (imgSize.Height / 9)), }; var textGraphicOptions = new TextGraphicsOptions(true) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }; // Apply Banner context.DrawBanner(settings) .DrawText(textGraphicOptions, settings.Text, scaledFont, settings.TextColor, center); return(context); }