How can i resize 4 images and place them in equal sizes in 1 file.


How can i resize 4 images and place them in equal sizes in 1 file.
I have 400 + Pictures in a folder i want a script that can make these just 100 files by resizing them smaller in equal shares and place 4 images in 1 file and name them 1,2,3,4.jpg.

So when opened i can see 4 images in 1 mspaint or windows Photo gallery.

LVL 11
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
I'm not aware of any way to do this in pure VBScript (.vbs) or CMD would need to call out to an external application or library.

You could do it in C# or VB.Net Express, both of which are FREE from Microsoft:
bsharathAuthor Commented:
Any way is ok if i can achieve it. Please let me know what i need to do....
Mike TomlinsonMiddle School Assistant TeacherCommented:
Here is a quick knock up using VB.Net 2005 Express:

Imports System.IO
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim thumbSize As New Size(250, 250)
        Dim bmp As New Bitmap(thumbSize.Width * 2, thumbSize.Height * 2)
        Dim g As Graphics = Graphics.FromImage(bmp)
        Dim folder As String = "c:\"
        Dim FileNames As New List(Of String)
        Dim newFileName As String
        Dim counter As Integer
        Dim counter2 As Integer
        Dim pb As New PictureBox
        pb.BorderStyle = BorderStyle.None
        pb.SizeMode = PictureBoxSizeMode.Zoom
        pb.Size = thumbSize
        For Each fi As FileInfo In New DirectoryInfo(folder).GetFiles("*.jpg")
            counter2 = counter2 + 1
            pb.Image = New Bitmap(fi.FullName)
            Select Case counter2
                Case 1
                    pb.DrawToBitmap(bmp, New Rectangle(0, 0, thumbSize.Width, thumbSize.Height))
                Case 2
                    pb.DrawToBitmap(bmp, New Rectangle(thumbSize.Width, 0, thumbSize.Width, thumbSize.Height))
                Case 3
                    pb.DrawToBitmap(bmp, New Rectangle(0, thumbSize.Height, thumbSize.Width, thumbSize.Height))
                Case 4
                    pb.DrawToBitmap(bmp, New Rectangle(thumbSize.Width, thumbSize.Height, thumbSize.Width, thumbSize.Height))
                    counter2 = 0
            End Select
            counter = counter + 1
            If FileNames.Count = 4 Then
                newFileName = Path.Combine(folder, String.Join(",", FileNames.ToArray) & ".jpg")
                bmp.Save(newFileName, System.Drawing.Imaging.ImageFormat.Jpeg)
                bmp = New Bitmap(thumbSize.Width * 2, thumbSize.Height * 2)
                g = Graphics.FromImage(bmp)
            End If
        If FileNames.Count > 0 Then
            newFileName = Path.Combine(folder, String.Join(",", FileNames.ToArray) & ".jpg")
            bmp.Save(newFileName, System.Drawing.Imaging.ImageFormat.Jpeg)
        End If
    End Sub
End Class

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

bsharathAuthor Commented:
Thank U Idle_Mind

Now can i know which software i need to download and do what. Just once if you can instruct me i shall keep that in mind...
Mike TomlinsonMiddle School Assistant TeacherCommented: VB.Net 2005 Express from the link I gave.  ...or you could download the newer VB.Net 2008 Express.  Either would work and both are free.  All you have to do is register it once you have it installed.  It's pretty easy.

Then you start with a "WinForms" Project (Windows Application) which gives an app with just one default form (Form1).

Right Click the Form and select "View Code".
Paste the code above over the ENTIRE default code.

Change this line so it reflects the folder you want to work with:

    Dim folder As String = "c:\"

Run the application...

bsharathAuthor Commented:
I get this error
Mike TomlinsonMiddle School Assistant TeacherCommented:
You need to add a Button (Button1) to your Form.
bsharathAuthor Commented:
bsharathAuthor Commented:
Thanks a lot it worked great....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.