2016-10-24 22 views
1

我正在嘗試使用WebImage調整圖像大小,但我需要所有的邊都是平等的,例如:width: 200 and height: 200,但保存圖像後保持不變,比例變化爲200x65。我怎麼能這樣做?如何使用WebImage調整圖像大小?

嘗試。

public class SaveImage{ 

    public static void save(HttpPostedFileBase image, String pathFile, String imgName){   
     String extension = Path.GetExtension(image.FileName); 
     String pathToSave = HttpContext.Current.Server.MapPath(pathFile); 
     WebImage wi = new WebImage(image.InputStream);   
     wi.Resize(width:200, height:200, preserveAspectRatio:true, preventEnlarge:true); 
     String imgToSave = Path.Combine(pathToSave, imgName + extension); 
     wi.Save(imgToSave); 
    } 

} 

回答

0

解決了這個問題,我做了:wi.Resize(width:200, height:200, preserveAspectRatio:false, preventEnlarge:false);它工作正常。