thumbnail for image method

  public async Task<string> SaveCompanythumbPhoto(UploadedFile LeadImage)
        {
            string fg = "";
            if (Session["tempimage"] != null)
            {
                fg = Session["tempimage"].ToString();

            }
            if (LeadImage != null)
            {
                string target = Server.MapPath("~/UploadedImages");
                if (!Directory.Exists(target))
                {
                    Directory.CreateDirectory(target);
                }
                // RadAsyncUpload1.UploadedFiles[0].SaveAs(Path.Combine(target, RadAsyncUpload1.UploadedFiles[0].GetName()));
                using (Bitmap originalImage = new Bitmap(LeadImage.InputStream))
                {
                    int width = 350;
                    int height = 350;
                    Bitmap thumbnail = new Bitmap(width, height);
                    using (Graphics g = Graphics.FromImage((System.Drawing.Image)thumbnail))
                        g.DrawImage(originalImage, 0, 0, width, height);
                    string thumbnailFileName = Path.Combine(target,
                        string.Format("{0}_bthumb{1}", LeadImage.GetNameWithoutExtension(), LeadImage.GetExtension()));
                    thumbnail.Save(thumbnailFileName);

                    var IMAGEURL = await bs.UploadImageAsync1(thumbnailFileName, LeadImage.GetExtension(), LeadImage.ContentType);
                    fg = IMAGEURL;
                    if ((System.IO.File.Exists(thumbnailFileName)))
                    {
                        System.IO.File.Delete(thumbnailFileName);
                    }
                    Session["tempimage"] = fg;
                }

            }
            return fg;
        }



===============

  protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
        {
         ViewState["orgprofile"]=SaveCompanyPhotof(RadAsyncUpload1.UploadedFiles[0]).Result;
         string path = SaveCompanythumbPhoto(RadAsyncUpload1.UploadedFiles[0]).Result;
            profilepic.ImageUrl = path;
        }

Comments

Popular posts from this blog

Create Schema Using C# Asp .Net Dynamically.

FAQ BIND

resgination mail