public IHttpActionResult UploadMeetLivePicture()
        {
            ReturnValueModel rvm = new ReturnValueModel();

            try
            {
                var root        = HostingEnvironment.MapPath("~/");
                var req         = HttpContext.Current.Request;
                var files       = req.Files;
                var inputStream = files[0].InputStream;

                var stream = GDIHelp.StreamToBytes(inputStream);

                var bitmap = GDIHelp.BytToImg(stream);
                bitmap = GDIHelp.Resize(bitmap, 375, 210);
                //按钮图片
                var buttonBitmap = GDIHelp.ReadImageFile(root + @"\Content\images\LivePicture.png");

                var width  = bitmap.Width / 2 - buttonBitmap.Width / 2;
                var height = bitmap.Height / 2 - buttonBitmap.Height / 2 - 3;
                bitmap = GDIHelp.DrawImage(bitmap, bitmap.Width, bitmap.Height, buttonBitmap, buttonBitmap.Width, buttonBitmap.Height, width, height);

                var filePath = @"Upload/MeetLivePicture";
                var newName  = Guid.NewGuid().ToString();
                var path     = root + filePath;

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path = path + "/" + newName;
                var saveName = GDIHelp.Save(bitmap, path);


                //var ext = files[0].FileName.Substring(files[0].FileName.LastIndexOf("."));
                //var fileName = Guid.NewGuid().ToString() + ext;
                //files[0].SaveAs(path + @"/" + fileName);

                var ext = saveName.Substring(saveName.LastIndexOf("."));
                rvm.Msg     = "success";
                rvm.Success = true;
                rvm.Result  = new
                {
                    url = $"{filePath}/{newName}{ext}",
                };
            }
            catch (Exception e)
            {
                rvm.Msg     = "";
                rvm.Success = false;
                rvm.Result  = e.Message;
            }
            return(Ok(rvm));
        }
        public IHttpActionResult UploadBanner()
        {
            var root  = HostingEnvironment.MapPath("~/");
            var req   = HttpContext.Current.Request;
            var files = req.Files;
            //List<string> list = new List<string>();
            List <FileInfoModel> list = new List <FileInfoModel>();
            var filePath = @"Upload/WeChatBanner";
            var path     = root + filePath;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            FileInfoModel fileInfo;

            for (int i = 0; i < files.Count; i++)
            {
                string mineType    = MimeMapping.GetMimeMapping(files[i].FileName);
                var    inputStream = files[i].InputStream;
                var    stream      = GDIHelp.StreamToBytes(inputStream);
                var    bitmap      = GDIHelp.BytToImg(stream);

                int width = 750;
                int fitWidth;
                int fitHeight;

                if (bitmap.Width > width)
                {
                    fitWidth  = width;
                    fitHeight = (bitmap.Height * width) / bitmap.Width;//(bitmap.Height * height) / bitmap.Width;
                }
                else
                {
                    fitWidth  = bitmap.Width;
                    fitHeight = bitmap.Height;
                }

                //if (bitmap.Width / bitmap.Height >= width / height)
                //{
                //    if (bitmap.Width > width)
                //    {
                //        fitWidth = width;
                //        fitHeight = (bitmap.Height * width) / bitmap.Width;//(bitmap.Height * height) / bitmap.Width;
                //    }
                //    else
                //    {
                //        fitWidth = bitmap.Width;
                //        fitHeight = bitmap.Height;
                //    }
                //}
                //else
                //{
                //    if (bitmap.Height > height)
                //    {
                //        fitHeight = height;
                //        fitWidth = (bitmap.Width * height) / bitmap.Height;
                //    }
                //    else
                //    {
                //        fitWidth = bitmap.Width;
                //        fitHeight = bitmap.Height;
                //    }
                //}

                bitmap = GDIHelp.Resize(bitmap, fitWidth, fitHeight);
                var newName = Guid.NewGuid().ToString();
                path = path + "/" + newName;
                var saveName = GDIHelp.Save(bitmap, path, mineType);

                var ext = saveName.Substring(saveName.LastIndexOf("."));

                fileInfo = new FileInfoModel();
                var fileName = $"{newName}{ext}";
                fileInfo.name = fileName;
                fileInfo.url  = $"{filePath}/{newName}{ext}";
                list.Add(fileInfo);
            }
            ReturnValueModel rvm = new ReturnValueModel();

            if (list.Count > 0)
            {
                rvm.Msg     = "success";
                rvm.Success = true;
                rvm.Result  = new
                {
                    list = list
                };
            }
            return(Ok(rvm));
        }