Fork me on GitHub

This filter can be used in several ways depending on the effect you wish to achieve.

There are five modes available for the Resize filter.

By default, images will not be enlarged if they are smaller than the target size. However, you can set the EnlargeImage property to true to allow enlargement.

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

@Html.DynamicImageTag(b => b.WithLayer(
	LayerBuilder.Image.SourceFile("~/Assets/Images/AutumnLeaves.jpg")
		.WithFilter(FilterBuilder.Resize.ToHeight(200))
))

@Html.DynamicImageTag(b => b.WithLayer(
	LayerBuilder.Image.SourceFile("~/Assets/Images/AutumnLeaves.jpg")
		.WithFilter(FilterBuilder.Resize.To(200, 200, ResizeMode.UniformFill))
))

@Html.DynamicImageTag(b => b.WithLayer(
	LayerBuilder.Image.SourceFile("~/Assets/Images/AutumnLeaves.jpg")
		.WithFilter(FilterBuilder.Resize.To(200, 200))
))

@Html.DynamicImageTag(b => b.WithLayer(
	LayerBuilder.Image.SourceFile("~/Assets/Images/AutumnLeaves.jpg")
		.WithFilter(FilterBuilder.Resize.To(Unit.Percentage(50), Unit.Percentage(50)))
))