locked
What do you think about this way of rezing? RRS feed

  • Question

  • User-663248805 posted

    hi i use thise code rezigin images on my application.

    Is it a good way for making thumbnail or? 

     

    protected
    void Button1_Click(object sender, EventArgs e)

    {

     

     

    string name = User.Identity.Name;

    string filename = FileUpload1.FileName;

    string uploadpath = @"C:\Documents and Settings\john\Desktop\app\photo\" + name + ".jpg";string thumbPath = @"C:\Documents and Settings\john\Desktop\app\thumb\";

     

    if (FileUpload1.HasFile)

    {

     

    System.Drawing.Image myimg = System.Drawing.Image.FromFile(uploadpath);

    double desiredHeight = System.Math.Round((myimg.Height * 0.45), 2);

    double desiredWidth = System.Math.Round((myimg.Width * 0.45), 2);

    myimg = myimg.GetThumbnailImage(Convert.ToInt16(desiredWidth), Convert.ToInt16(desiredHeight), null, IntPtr.Zero);

     

    Label1.Text =
    "You filename has been uploaded successfuly";

    myimg.Save(thumbPath + filename, myimg.RawFormat);

     

    }

    }

    Tuesday, June 17, 2008 8:33 AM

All replies

  • User-1426124666 posted

    Yes that is fine for creating a thumnailed image (although you may want to just save the thumbnail directly rather than assigning it back to the original object). Why do you ask? Are you having performance problems? Or are you not getting what you expected?

    Tuesday, June 17, 2008 9:07 AM
  • User-663248805 posted

    well thanks for reply

     I am new to programming and c#

    It works, i just asked to see if i am doing it the right way.

    Tuesday, June 17, 2008 4:56 PM