Created
May 21, 2012 18:45
-
-
Save benfoster/2763877 to your computer and use it in GitHub Desktop.
Fluent Extensions for Image Resizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
ViewBag.Title = "Index"; | |
var builder = new ImageBuilder() | |
.Resize(img => img.Width(400).Height(300).Crop()) | |
.Transform(img => img.FlipAfter(FlipType.X)) | |
.Style(img => img.PaddingWidth(10).PaddingColor("FF0066").Margin(20).BackgroundColor("000000")) | |
.Output(img => img.Quality(90).Format(OutputFormat.Png)); | |
} | |
<h2>Index</h2> | |
<h4>Max Height</h4> | |
@Html.BuildImage("~/images/image.jpg", x => x.Resize(img => img.MaxHeight(200)).Output(img => img.Quality(90))) | |
<h4>Max Width</h4> | |
@Html.BuildImage("~/images/image.jpg", x => x.Resize(img => img.MaxWidth(200))) | |
<h4>Fixed width and height with background color</h4> | |
@Html.BuildImage("~/images/image.jpg", x => x.Resize(img => img.Dimensions(200, 200)).Style(img => img.BackgroundColor("000000"))) | |
<h4>Cropped image</h4> | |
@Html.BuildImage("~/images/image.jpg", x => x.Resize(img => img.Dimensions(200, 200).Crop().Anchor(AnchorPoint.BottomRight))) | |
<h4>Flipped</h4> | |
@Html.BuildImage("~/images/image.jpg", x => x.Resize(img => img.MaxHeight(200)).Transform(img => img.FlipAfter(FlipType.XY))) | |
<h4>Rotated</h4> | |
@Html.BuildImage("~/images/image.jpg", x => x.Resize(img => img.Dimensions(200, 200)) | |
.Transform(img => img.Rotate(RotateType.Rotate90)) | |
.Style(img => img.BorderWidth(5).BorderColor("000000"))) | |
<h4>Using existing builder</h4> | |
@Html.BuildImage("~/images/image.jpg", builder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment