Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-26
9
Medium Priority
?
279 Views
Last Modified: 2012-05-05
Hi,

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.

Regards
sharath
0
Comment
Question by:bsharath
  • 5
  • 4
9 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22807688
I'm not aware of any way to do this in pure VBScript (.vbs) or CMD Scripting...you 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:
http://www.microsoft.com/express/product/
0
 
LVL 11

Author Comment

by:bsharath
ID: 22807696
Any way is ok if i can achieve it. Please let me know what i need to do....
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 22816822
Here is a quick knock up using VB.Net 2005 Express:
http://www.microsoft.com/express/2005/download/default.aspx

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
            FileNames.Add(counter.ToString("00"))
 
            If FileNames.Count = 4 Then
                newFileName = Path.Combine(folder, String.Join(",", FileNames.ToArray) & ".jpg")
                g.Dispose()
                bmp.Save(newFileName, System.Drawing.Imaging.ImageFormat.Jpeg)
 
                bmp = New Bitmap(thumbSize.Width * 2, thumbSize.Height * 2)
                g = Graphics.FromImage(bmp)
                FileNames.Clear()
            End If
        Next
 
        If FileNames.Count > 0 Then
            newFileName = Path.Combine(folder, String.Join(",", FileNames.ToArray) & ".jpg")
            bmp.Save(newFileName, System.Drawing.Imaging.ImageFormat.Jpeg)
            g.Dispose()
        End If
 
        MessageBox.Show("Done!")
    End Sub
 
End Class

Open in new window

01-02-03-04.jpg
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Author Comment

by:bsharath
ID: 22818791
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...
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22818835
Yeah...download 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...

0
 
LVL 11

Author Comment

by:bsharath
ID: 22819120
I get this error
Untitled.jpg
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22819405
You need to add a Button (Button1) to your Form.
0
 
LVL 11

Author Comment

by:bsharath
ID: 22819437
Button?
0
 
LVL 11

Author Comment

by:bsharath
ID: 22819447
Thanks a lot it worked great....
:-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month6 days, 2 hours left to enroll

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question