Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ImageresizeImageresize
Previous
 
Next
New Post
12/18/2008 10:44 PM
 

hi,

Subject: ImageResize in else statement.

i am using asp.net with c# using dotnetnuke.

when i upload a image it will check the valid image width and height size.

if it is valid saved. if it is invalid got to resize.

for example:

This is my code to check the valid image width and height size.
=======
protected void cmdUpdate_Click(System.Object sender, System.EventArgs e)
 {

using (System.Drawing.Bitmap objmap = new System.Drawing.Bitmap(FileUpload1.PostedFile.InputStream, false))
                {
            int one, two;
                    string path2 = "";
                    one = Convert.ToInt32(fixedWide);
                    two = Convert.ToInt32(fixedHgt);
                    if (objmap.Width == one && objmap.Height == two)
                    {
                        path1 = FileUpload1.PostedFile.FileName.ToString();
                        path2 = path1.Substring(path1.LastIndexOf("\\") + 1);

                        string getimagepath = Server.MapPath(@"~\ImageFolders\");
                        getimagepath = getimagepath  + Convert.ToString(ModuleId) + "_img_" + path2;
                        FileUpload1.SaveAs(getimagepath);
                        lblMsg.Text = "filesaved";
                    }
                    else
                    {
                        lblMsg.Text = "Please give valid image size...";
                    }
                }
}
=====
This code is run good.my question is: how to call the resize function in else statement.
i don't know how to do image resize function. so, please give some idea and related reference source.

and

i just cut and paste this code in my else part statement: but i don't know this is correct or not?

Please verify where can i made mistake?

This is my full code for imageupload:

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

protected void cmdUpdate_Click(System.Object sender, System.EventArgs e)
 {

    using (System.Drawing.Bitmap objmap = new System.Drawing.Bitmap(FileUpload1.PostedFile.InputStream, false))
                {
            int one, two;
                    string path2 = "";
                    one = Convert.ToInt32(fixedWide);
                    two = Convert.ToInt32(fixedHgt);
                    if (objmap.Width == one && objmap.Height == two)
                    {
                        path1 = FileUpload1.PostedFile.FileName.ToString();
                        path2 = path1.Substring(path1.LastIndexOf("\\") + 1);

                        string getimagepath = Server.MapPath(@"~\ImageFolders\");
                        getimagepath = getimagepath  + Convert.ToString(ModuleId) + "_img_" + path2;
                        FileUpload1.SaveAs(getimagepath);
                        lblMsg.Text = "filesaved";
                    }
                    else
                    {
                        path1 = FileUpload1.PostedFile.FileName.ToString();
                        path2 = path1.Substring(path1.LastIndexOf("\\") + 1);

                        string getimgfolpath = Server.MapPath(@"~\DesktopModules\Demo\ImageFolders\");
                        getimgfolpath = getimgfolpath + Convert.ToString(ModuleId) + "_img_" + path2;
                        FileUpload1.SaveAs(getimgfolpath);
                        ImageResizeoption(getimgfolpath,path2);
                    }
                }
}


                       

     public void ImageResizeoption(string parmFileIn, string Userid)
        {

            string filePathSourceFile = HttpContext.Current.Server.MapPath(@"~\ImageFolders\" + ModuleId.ToString() + "/");
          
            string fullSourceFile = parmFileIn;
            int thumbnailHeight,thumbnailWidth;
         
            System.Drawing.Image sourceImage = System.Drawing.Image.FromFile(parmFileIn);
            thumbnailHeight = 181;
            thumbnailWidth = 358;           
            System.Drawing.Image thumbnailImage = sourceImage.GetThumbnailImage(thumbnailWidth, thumbnailHeight, null, IntPtr.Zero);          
            MemoryStream imageStream = new MemoryStream();          
            thumbnailImage.Save(imageStream, System.Drawing.Imaging.Imageformat.Jpeg);          
            string outfile = filePathSourceFile + "s" + ModuleId + "_" + Userid;         
            try
            {
                thumbnailImage.Save(outfile);
              
            }
            catch (Exception e)
            {
                string dummy = e.ToString();
                return;
            }
        }
==========================================


In the complete code doesnot shown any error message.

Please see where i made mistake in my code(else part statement).

Many Thanks

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ImageresizeImageresize


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out