public bool ShouldProcessImagePath(HttpRequest request, out ImageResizeInfo imageResizeInfo) { imageResizeInfo = null; if (request.Path == null || !request.Path.HasValue) { return(false); } bool isImagePath = imageExtensions.Any(x => request.Path.Value.EndsWith(x, StringComparison.InvariantCultureIgnoreCase)); if (isImagePath) { imageResizeInfo = new ImageResizeInfo { Width = int.TryParse(request.Query["width"], out int width) ? width : (int?)null, Height = int.TryParse(request.Query["height"], out int height) ? height : (int?)null, Quality = int.TryParse(request.Query["quality"], out int quality) ? quality : (int?)null, Mode = Enum.TryParse(request.Query["mode"], out ImageMode mode) ? mode : (ImageMode?)null, Format = Enum.TryParse(request.Query["format"], out ImageFormat format) ? format : (ImageFormat?)null }; return(imageResizeInfo.HasResize); } return(false); } }
public override bool Equals(object obj) { ImageResizeInfo other = (ImageResizeInfo)obj; if (SourceImage == null || other.SourceImage == null) { return(false); } return(ImageResizeControl.GetUniqueSourceId(SourceImage) == ImageResizeControl.GetUniqueSourceId(other.SourceImage) && WidthResizeInfo.Equals(other.WidthResizeInfo) && HeightResizeInfo.Equals(other.HeightResizeInfo)); }
public Task <Stream> ProcessAsync(Stream source, ImageResizeInfo imageResizeInfo) { return(ProcessImageAsync(source, imageResizeInfo.Width ?? 0, imageResizeInfo.Height ?? 0, imageResizeInfo.Quality ?? 95, imageResizeInfo.Mode ?? ImageMode.CropScale, imageResizeInfo.Format)); }