public HttpResponseMessage GetWHImage(string name, int?wd, int?hg) { HttpResponseMessage response = new HttpResponseMessage(); var httpRequest = HttpContext.Current.Request; string username = httpRequest.Params.Get("username"); string token = httpRequest.Params.Get("token"); if (!ValidPermission(username, token)) { return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Permission Denied")); } string directory = physicalPath + "/" + name; if (File.Exists(directory)) { FileStream fs = new FileStream(directory, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); byte[] imageByte = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); string imageTypeFormName = name.Split('.')[1]; Enum imageTypeEnum = (Enum)System.Enum.Parse(typeof(ImageType), imageTypeFormName); string imageType = ImageType.jpg.GetDisplayName(); IImageInfo img = WebManager.GetImageInfoByByte(imageByte, name, imageType); IImageInfo newImg = img.ResizeMeV2(hg, wd); response.Content = new ByteArrayContent(newImg.PhotoStream); response.Content.Headers.ContentType = new MediaTypeHeaderValue(imageType); } else { return(Request.CreateResponse(HttpStatusCode.OK, "Exsited")); } return(response); }