i've been looking into the awesome imageresizing.net tool, and am successfully using the URL API on my site.
However, i'm keen to look into the managed API, and resize a photo AS it is uploaded. I have started off by building a very basic upload page that uses the WebImage helper:
@using ImageResizer;
@{
WebImage photo = null;
var newFileName = "";
var imagePath = "";
if(IsPost){
photo = WebImage.GetImageFromRequest();
if(photo != null){
newFileName = Guid.NewGuid().ToString() + "_" +
Path.GetFileName(photo.FileName);
imagePath = @"images\" + newFileName;
photo.Save(@"~\" + imagePath);
}
}
}
I want to use the ImageResizing tool in this upload, to resize/crop to a specific size.
Below is the code that i need to insert (i have tested this by running on an existing image, and it works fine):
ImageResizer.ImageBuilder.Current.Build(imagePath,imagePath,
new ResizeSettings("width=620&height=405&mode=crop"));
Any idea house i can merge the two, and resize BEFORE i save?