Fork me on GitHub

Install the DynamicImage.Extensions.ContentAwareResizing package to get this extension. There is some background information in this blog post.

@Html.DynamicImageTag(b => b.WithLayer(
	LayerBuilder.Image.SourceFile("~/Assets/Images/tower.jpg")
		.WithFilter(FilterBuilder.Resize.ToWidth(500))
))

@Html.DynamicImageTag(b => b.WithLayer(
	LayerBuilder.Image.SourceFile("~/Assets/Images/tower.jpg")
		.WithFilter(FilterBuilder.Resize.ToWidth(500))
		.WithFilter(FilterBuilder.Resize.To(350, 412, ResizeMode.Fill))
))

@Html.DynamicImageTag(b => b.WithLayer(
	LayerBuilder.Image.SourceFile("~/Assets/Images/tower.jpg")
		.WithFilter(FilterBuilder.Resize.ToWidth(500))
		.WithFilter(new ContentAwareResizeFilterBuilder().ToWidth(350)
			.ConvolutionType(ContentAwareResizeFilterConvolutionType.V1))
))