public static void ResizeCanvas(this IImageProcessingContext context, double?pad, string padColorNameOrHexString) { if (pad is null || pad.Value < 1) { return; } var scale = (double)pad; var color = ColorUtils.TryParse(padColorNameOrHexString, out var result) ? result : Color.Transparent; var size = context.GetCurrentSize(); var height = (int)(size.Height * scale); var width = (int)(size.Width * scale); context.Pad(width, height, color); }
/// <summary> /// Evenly pads an image to fit the new dimensions. /// </summary> /// <param name="source">The source image to pad.</param> /// <param name="width">The new width.</param> /// <param name="height">The new height.</param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Pad(this IImageProcessingContext source, int width, int height) => source.Pad(width, height, default);