Visual Basic 2010 – Resize any image to any size and save it (jpg, gif, png, tiff, etc)

26
30



In this video I will show you how to write a program in vb 2010 to resize an image in any format, then save it based on a format the user chooses. I only demostrate how to deal with jpg and gif, but you can apply the same programming techniques to customize your program. Please rate, comment, and enjoy!

Nguồn:https://wijstaanvooronzegrondrechten.org/

26 COMMENTS

  1. and then when I want to save to the database how? please tell me tuttorial resize image before save to database mysql? 🙂 thanks before

  2. Again, hats off for a great Tutorial. I changed a few things as we went along that others might find useful.

    1. In Form Load, I set the ImageSizeLable.Text = Rectangle.Size.ToString
    2. Where you have NewSize, I omitted this and just used Rectangle.Size to keep from using another variable.
    3. At the end of the OpenFileDialog If statement I added ImagePathGroupBox.Width = ImagePathLabel.Width + 25 to allow room for long paths.
    4. I changed "SaveFileDialog.DefaultExt = Path.GetExtension(ImagePathLabel.Text)" to "SaveFileDialog.DefaultExt = System.IO.Path.GetExtension(ImagePathLabel.Text)" so no Imports were needed. Imports only help to keep from having to retype the same stuff over and over.

    The reasons for my changes are simple. Teacher implored that we should always code with flexibility. If a user just resized the rectangle, nothing in the code will need to be changed with my additions.

    Extra Credit: Add flexibility so the rectangle can be resized at runtime. Try to go as far as to keep the rectangle proportional to the original image. 

    For those with bad eyesight like mine, the filters for the OpenFileDialog is "jpg and gif|*.jpg;*.gif"

  3. Great Tute. Quality of video a bit too low. Can't read what you put as filter. Perhaps zooming would help if you keep this fuzzy quality of 480.

  4. try this steps:
    remove the background image i.e: None
    now your 1st and 2nd error will remove and 3rd error:
    please check the code again…
    here it's seems your mistake in the code

LEAVE A REPLY

Please enter your comment!
Please enter your name here