public IHttpActionResult PhotoUpload(MessageImageDto dto)
        {
            try
            {
                Image image;
                MemoryStream ms = new MemoryStream(dto.imageData);
                image = Image.FromStream(ms);
                Guid imageid = Guid.NewGuid();

                string uploadPath = HttpContext.Current.Server.MapPath("/Content/Photo/Original/");
                Bitmap bt1 = ResizeImage(image, Convert.ToInt32(Math.Ceiling(image.Width * 0.3)), Convert.ToInt32(Math.Ceiling(image.Height * 0.3)));
                bt1.Save(uploadPath + imageid + ".jpg");

                string thumbnailupload = HttpContext.Current.Server.MapPath("/Content/Photo/Thumbnail/");
                Bitmap bt = ResizeImage(image, 300, 300);
                bt.Save(thumbnailupload + imageid + ".jpg");

                var fileNameOrginal = "/Content/Photo/Original/" + imageid + ".jpg";
                var fileNameThumbnail = "/Content/Photo/Thumbnail/" + imageid + ".jpg";

                return Json(fileNameThumbnail);
            }
            catch (Exception)
            {
                return Json("test");
            }
        }
Пример #2
0
        public IHttpActionResult PhotoUpload(MessageImageDto dto)
        {
            try
            {
                Image        image;
                MemoryStream ms = new MemoryStream(dto.imageData);
                image = Image.FromStream(ms);
                Guid imageid = Guid.NewGuid();

                string uploadPath = HttpContext.Current.Server.MapPath("/Content/Photo/Original/");
                Bitmap bt1        = ResizeImage(image, Convert.ToInt32(Math.Ceiling(image.Width * 0.3)), Convert.ToInt32(Math.Ceiling(image.Height * 0.3)));
                bt1.Save(uploadPath + imageid + ".jpg");

                string thumbnailupload = HttpContext.Current.Server.MapPath("/Content/Photo/Thumbnail/");
                Bitmap bt = ResizeImage(image, 300, 300);
                bt.Save(thumbnailupload + imageid + ".jpg");

                var fileNameOrginal   = "/Content/Photo/Original/" + imageid + ".jpg";
                var fileNameThumbnail = "/Content/Photo/Thumbnail/" + imageid + ".jpg";

                return(Json(fileNameThumbnail));
            }
            catch (Exception)
            {
                return(Json("test"));
            }
        }