public static PostImage CreateFromPostedFile(HttpPostedFileBase newImage) { var binaryReader = new BinaryReader(newImage.InputStream); var fileData = binaryReader.ReadBytes(newImage.ContentLength); PostImage image = new PostImage { Image = fileData, DateTime = DateTime.Now }; return image; }
public PostImage AddImage(PostImage image) { image = _db.Images.Add(image); _db.SaveChanges(); return image; }
private static MemoryStream ResizeImage(PostImage postImage, int height , int width) { MemoryStream outStream; using (outStream = new MemoryStream()) { using (var inStream = new MemoryStream(postImage.Image)) { var settings = new ResizeSettings("maxwidth="+width+"&maxheight="+height); ImageResizer.ImageBuilder.Current.Build(inStream, outStream, settings); postImage.Image = outStream.ToArray(); // return new FileContentResult(outBytes, "image/jpeg"); } } return outStream; }
private PostImage UploadPicture(HttpPostedFileBase NewImage, string caption) { var binaryReader = new BinaryReader(NewImage.InputStream); var fileData = binaryReader.ReadBytes(NewImage.ContentLength); PostImage image = new PostImage { Image = fileData, DateTime = DateTime.Now, Caption = caption}; return _blogPostDao.AddImage(image); }
private static MemoryStream ReizeImage(PostImage postImage) { return ResizeImage(postImage, 1000, 1000); }