Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ImageOutputCache(Duration = 3000, Location = System.Web.UI.OutputCacheLocation.Client)]
- public void GetPic(string fn, int? w, int? h)
- {
- try
- {
- if (w > 1920) { w = 1920; }
- if (h > 1080) { h = 1080; }
- WebImage wi = new WebImage(@"~/img/" + fn);
- if (!h.HasValue)
- {
- Single ratio = (Single)wi.Width / (Single)wi.Height;
- h = (int)Math.Ceiling(wi.Width / ratio);
- }
- wi
- .Resize(w.Value + 1, h.Value + 1, true, true) // Resizing the image to 100x100 px on the fly...
- .Crop(1, 1) // Cropping it to remove 1px border at top and left sides (bug in WebImage)
- .Write();
- }
- catch
- {
- //new WebImage(@"~/img/default.jpg").Write();
- //Redirect(@"~/img/default.jpg");
- }
- }
Add Comment
Please, Sign In to add comment