resize all/multiple images at once from folder / subfolder by c# in any size

for image processing first step is get a proper sized image. and maximum time need many images resizing at once. it easy but take lot of time. so i made a programme to do that in a second, which u can get here with full source code.

steps are

  • select folder.
  • make a list of all images file from that folder including subfolder as user wish.
  • resize all of them
  • save the images

so for select folder we use Folderbowserdialog ,

private void button4_Click(object sender, EventArgs e)
FolderBrowserDialog f = new FolderBrowserDialog();
if (f.ShowDialog() == DialogResult.OK) // selecting directory
textBox2.Text = f.SelectedPath;
DirectoryInfo Folder;

Folder = new DirectoryInfo(f.SelectedPath);//take all directoryinfo
if (checkBox1.Checked)
Images = Folder.GetFiles(".", SearchOption.AllDirectories);//for subfolders
Images = Folder.GetFiles(".", SearchOption.TopDirectoryOnly);// for only current folder

int j = 0;
for (int i = 0; i < Images.Length; i++)
if (Images[i].FullName.Contains(".jpg") || Images[i].FullName.Contains(".bmp") || Images[i].FullName.Contains(".jpeg"))//check are they images or not

Bitmap bmp = new Bitmap(Images[i].FullName);//get image
PictureBox p = new PictureBox();

p.Image = bmp;
p.Height = bmp.Height;
p.Width = bmp.Width;
flowLayoutPanel1.Controls.Add(p); //show in picturebox uing flowpanel


catch (Exception a) { MessageBox.Show("unauthorized access"); }//exception from protected directory


so we get all the imagefile in our fileinfo clss images now for resize and save we have to write

 for (int i = 0; i < Images.Length; i++)//take all image file

                    if (Images[i].FullName.Contains(".jpg") || Images[i].FullName.Contains(".bmp") || Images[i].FullName.Contains(".jpeg"))
                        Bitmap bmp = new Bitmap(Images[i].FullName);
                        int resizedW = Convert.ToInt16(numericUpDown3.Value);
                        int resizedH = Convert.ToInt16(numericUpDown4.Value);

                        bmpResized = new Bitmap(bmp, resizedW, resizedH); //resizing image
                        if (filepath != null)//saving image
                            bmpResized.Save(filepath + "\\" + Images[i].Name);
                        { bmpResized.Save(Images[i].DirectoryName + "\\" + i.ToString() + Images[i].Name); }

it is very simple and beginning level c# code hope it would be helpful


About kishordgupta

A software developer
This entry was posted in C#, Image Processing, Winform app and tagged , , , , , , , , . Bookmark the permalink.

4 Responses to resize all/multiple images at once from folder / subfolder by c# in any size

  1. fadedreamz says:

    nice article …. keep it up kishordgupta

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s