[OutputCache(Duration = (60 * 60 * 24 * 30 * 12), VaryByParam = "*")] // 1 year public ActionResult Render(string file, int width, int height) { var fullFilePath = GetFullFilePath(file); if (!System.IO.File.Exists(fullFilePath)) { return(Instantiate404ErrorResult(file)); } if (width > 0 || height > 0) { string fileExtension = Path.GetExtension(fullFilePath); string resizedFilePath = string.Format("{0}_{1}{2}", fullFilePath.Substring(0, fullFilePath.Length - fileExtension.Length), width + "x" + height, fileExtension); if (!System.IO.File.Exists(resizedFilePath)) { var imageResizer = new Simple.ImageResizer.ImageResizer(fullFilePath); imageResizer.Resize(width, height, Simple.ImageResizer.ImageEncoding.Jpg90); imageResizer.SaveToFile(resizedFilePath); } return(new ImageFileResult(resizedFilePath)); } return(new ImageFileResult(fullFilePath)); }
public ActionResult Render(string file, int width, int height) { var fullFilePath = GetFullFilePath(file); if (!System.IO.File.Exists(fullFilePath)) return Instantiate404ErrorResult(file); if (width > 0 || height > 0) { string fileExtension = Path.GetExtension(fullFilePath); string resizedFilePath = string.Format("{0}_{1}{2}", fullFilePath.Substring(0, fullFilePath.Length - fileExtension.Length), width + "x" + height, fileExtension); if (!System.IO.File.Exists(resizedFilePath)) { var imageResizer = new Simple.ImageResizer.ImageResizer(fullFilePath); imageResizer.Resize(width, height, Simple.ImageResizer.ImageEncoding.Jpg90); imageResizer.SaveToFile(resizedFilePath); } return new ImageFileResult(resizedFilePath); } return new ImageFileResult(fullFilePath); }