/// <summary> /// Public constructor /// </summary> /// <param name="width">The new width</param> /// <param name="height">The new height</param> /// <param name="resizeMode">The resize mode (default: ResizeMode.Pad)</param> /// <param name="backgroundColor">The background color (applies to ResizeMode.Pad) (Hex without the number sign, e.g. 'fff')</param> /// <param name="anchorPosition">The anchor position color (applies to ResizeMode.Crop)</param> /// <param name="upscale">To turn off upscaling (this does not affect stretched images)</param> public ImageProcessorResizeParameter(int? width = null, int? height = null, ImageProcessorResizeMode? resizeMode = null, string backgroundColor = "", ImageProcessorAnchorPosition? anchorPosition = null, bool? upscale = null) { if (!width.HasValue && !height.HasValue) throw new ArgumentNullException("At least width or height is required"); Width = width; Height = height; ResizeMode = resizeMode; BackgroundColor = backgroundColor; AnchorPosition = anchorPosition; Upscale = upscale; }
/// <summary> /// Get the ImageProcessor resize URL for the given image URL /// </summary> /// <param name="imageUrl">The image URL</param> /// <param name="width">The new width</param> /// <param name="height">The new height</param> /// <param name="resizeMode">The resize mode (default: ResizeMode.Pad)</param> /// <returns>The ImageProcessor resize URL</returns> public static string GetImageProcessorResizeUrl(this string imageUrl, int? width = null, int? height = null, ImageProcessorResizeMode? resizeMode = null) { return imageUrl.GetImageProcessorUrl(new ImageProcessorResizeParameter(width, height, resizeMode)); }