I'm using imageresizer, it works very well at run time:
foreach (string fileKey in Request.Files.Keys)
{
//Skip unused file controls.
var file = Request.Files[fileKey];
if (file.ContentLength <= 0) continue;
//Get the physical path for the uploads folder and make sure it exists
string desFolder = Server.MapPath("~/Data/ProductImages/") + productId.ToString();
if (!Directory.Exists(desFolder)) Directory.CreateDirectory(desFolder);
//string fileName;
string guid = System.Guid.NewGuid().ToString();
//Generate each version
foreach (string suffix in versions.Keys)
{
//Generate a filename (GUIDs are best).
string filePath = Path.Combine(desFolder, guid + suffix);
//Let the image builder add the correct extension based on the output file type
ImageBuilder.Current.Build(file, filePath, new ResizeSettings(versions[suffix]), false, true);
}
but get this warning from visual studio
ImageResizer.ImageBuilder.Build(object, object, Image Resizer.Resize Settings, bool, bool)' is obsolete: 'Use .Build(new Image Job(source, dest, settings, dispose Source, add FileExtension)).Final Path instead'
how fix it?
The solution is to use .Build(new Image Job(source, dest, settings, dispose Source, add FileExtension))
as the deprecation warning suggests.
Replace
ImageBuilder.Current.Build(file, filePath, new ResizeSettings(versions[suffix]), false, true);
with
ImageBuilder.Current.Build(new ImageJob(file,filePath, new Instructions(versions[suffix]),false,true))