C# ImageResizer-将图像另存为较大尺寸

C# ImageResizer-将图像另存为较大尺寸,c#,asp.net,.net,imageresizer,C#,Asp.net,.net,Imageresizer,我正在尝试使用.net将图像保存到指定的大小。我无法使用当前使用的代码将较小的图像保存为较大的尺寸。例如,我上传的图像是200x200,“拇指”版本将保存为100x100,但“中”和“大”版本仍将是200x200 如何将上载的图像保存到指定的较大图像?例如versions.Add(“_extralge”,“width=2000&height=2000&crop=auto&format=jpg”);或版本。添加(“XXL”,“宽度=自动&高度=3000&裁剪=自动&格式=jpg”) //Gener

我正在尝试使用.net将图像保存到指定的大小。我无法使用当前使用的代码将较小的图像保存为较大的尺寸。例如,我上传的图像是200x200,“拇指”版本将保存为100x100,但“中”和“大”版本仍将是200x200

如何将上载的图像保存到指定的较大图像?例如versions.Add(“_extralge”,“width=2000&height=2000&crop=auto&format=jpg”);或版本。添加(“XXL”,“宽度=自动&高度=3000&裁剪=自动&格式=jpg”)

//GenerateVersions(FileUpload1.PostedFile.FileName);
字典版本=新字典();
//定义要生成的版本
添加(“_thumb”,“宽度=100&高度=100&裁剪=auto&格式=jpg”)//裁剪成方形缩略图
添加(“_medium”,“maxwidth=400&maxheight=400&format=jpg”)//安装在400x400区域内,jpeg
添加(“_large”,“maxwidth=1900&maxheight=1900&format=jpg”)//安装在1900x1200区域内
//循环浏览每个上传的文件
foreach(HttpContext.Current.Request.Files.Keys中的字符串fileKey)
{
HttpPostedFile=HttpContext.Current.Request.Files[fileKey];

如果(file.ContentLength默认情况下,缩放模式设置为
downscale only
。根据需要将说明中的设置为


请注意,放大图像往往会产生模糊图像。

将低分辨率图像调整为更高分辨率并不会使其质量更高。相反,它会使图像模糊。是的。我可以使用分形插值或其他方法来调整放大的图像吗?
//GenerateVersions(FileUpload1.PostedFile.FileName);
Dictionary<string, string> versions = new Dictionary<string, string>();
//Define the versions to generate
versions.Add("_thumb", "width=100&height=100&crop=auto&format=jpg"); //Crop to square thumbnail
versions.Add("_medium", "maxwidth=400&maxheight=400&format=jpg"); //Fit inside 400x400 area, jpeg
versions.Add("_large", "maxwidth=1900&maxheight=1900&format=jpg"); //Fit inside 1900x1200 area

//Loop through each uploaded file
foreach (string fileKey in HttpContext.Current.Request.Files.Keys)
{
    HttpPostedFile file = HttpContext.Current.Request.Files[fileKey];
    if (file.ContentLength <= 0) continue; //Skip unused file controls.

    //Get the physical path for the uploads folder and make sure it exists
    string uploadFolder = MapPath("~/uploadsAIM");
    if (!Directory.Exists(uploadFolder)) Directory.CreateDirectory(uploadFolder);

    //Generate each version
    foreach (string suffix in versions.Keys)
    {
        ////Generate a filename (GUIDs are best).
        //string fileName = Path.Combine(uploadFolder, System.Guid.NewGuid().ToString() + suffix);
        string fileName = Path.Combine(uploadFolder, file.FileName + suffix);

        //Let the image builder add the correct extension based on the output file type
        //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true); //deprecated fileName
        fileName = ImageBuilder.Current.Build(new ImageJob(file, fileName, new Instructions(versions[suffix]), false, true)).FinalPath;
    }
}