public static byte[] ResizeFromByteArray(int MaxSideSize, Byte[] byteArrayIn, string fileName) { byte[] byteArray = null; // really make this an error gif MemoryStream ms = new MemoryStream(byteArrayIn); byteArray = ImageResize.ResizeFromStream(MaxSideSize, ms, fileName); return(byteArray); }
public static byte[] ResizeFromImagePath(int MaxSideSize, string ImagePath, string fileName) { byte[] byteArray = null; // really make this an error gif if (ImagePath.Contains("http://") || ImagePath.Contains("www.")) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ImagePath); request.Method = "GET"; request.Accept = "image/gif"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream s = response.GetResponseStream(); byteArray = ImageResize.ResizeFromStream(MaxSideSize, s, fileName); } else { byteArray = null; // really make this an error gif MemoryStream ms = new MemoryStream(System.IO.File.ReadAllBytes(System.Web.HttpContext.Current.Server.MapPath(ImagePath))); byteArray = ImageResize.ResizeFromStream(MaxSideSize, ms, fileName); } return(byteArray); }
public static void ResizeImage(int MaxSideSize, string ImagePath, RadBinaryImage radImage) { byte[] byteArray = null; // really make this an error gif if (ImagePath.Contains("http://") || ImagePath.Contains("www.")) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ImagePath); request.Method = "GET"; request.Accept = "image/gif"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream s = response.GetResponseStream(); byteArray = ImageResize.ResizeFromStream(MaxSideSize, s, "ProfilePic"); } else { byteArray = null; // really make this an error gif MemoryStream ms = new MemoryStream(System.IO.File.ReadAllBytes(System.Web.HttpContext.Current.Server.MapPath(ImagePath))); byteArray = ImageResize.ResizeFromStream(MaxSideSize, ms, "ProfilePic"); } radImage.DataValue = byteArray; radImage.ResizeMode = Telerik.Web.UI.BinaryImageResizeMode.Crop; }