472,371 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

creating thumbnails from .jpg

Hi, I'm a newbie to VB.NET and I am trying to create thumbnails from .jpg
files (my travel pictures) to
post on a website. I want to create an executable that I can put in a
directory containing my jpg images which will create the thumbnails with a
"-t.jpg" extenstion. I found this code below which will create a thumbnail
from a specified file, "randomphoto.jpg".

Sub Thumbnail()
Dim myCallback As System.Drawing.Image.GetThumbnailImageAbort
Dim myPtr As IntPtr
Dim myPic As New Bitmap("E:\randomphoto.jpg")
Dim myThumb As System.Drawing.Image = myPic.GetThumbnailImage(100, 100,
myCallback, myPtr)
myThumb.Save("E:\mythumb.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub

How can I alter this code to pick out any .jpg file in the current directory
and create a thumbnail. Do I use a looping structure to read each file and
run the above module? Any help in pointing me in the right direction
appreciated.
James
Jul 21 '05 #1
2 1645
Hi James,
Hi, I'm a newbie to VB.NET and I am trying to create thumbnails from
.jpg files (my travel pictures) to
post on a website. I want to create an executable that I can put in a
directory containing my jpg images which will create the thumbnails
with a "-t.jpg" extenstion. I found this code below which will
create a thumbnail from a specified file, "randomphoto.jpg".

Sub Thumbnail()
Dim myCallback As System.Drawing.Image.GetThumbnailImageAbort
Dim myPtr As IntPtr
Dim myPic As New Bitmap("E:\randomphoto.jpg")
Dim myThumb As System.Drawing.Image =
myPic.GetThumbnailImage(100, 100, myCallback, myPtr)
myThumb.Save("E:\mythumb.jpg",
System.Drawing.Imaging.ImageFormat.Jpeg) End Sub

How can I alter this code to pick out any .jpg file in the current
directory and create a thumbnail. Do I use a looping structure to
read each file and run the above module? Any help in pointing me in
the right direction appreciated.


Check the GetFiles()-method from the DirectoryInfo-Class, which gives you
all the files in a directory as FileInfo-Objects. You can use those in a
loop to create your thumbnails.

Regards,

Frank Eller
www.frankeller.de
Jul 21 '05 #2
Have a read of something like this.

http://support.microsoft.com/default...4&ID=kb;en-us;
Q303974&SD=MSDN

You could even automate the process. Why dont you try to find an example of
filesystemwatcher. If you made it watch for changes in the directory (ie.
new jpg's) then you could make it automatically create the thumbnails for
you.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"James" <ja***@nowhere.net> wrote in message
news:40**********************@news.dial.pipex.com. ..
Hi, I'm a newbie to VB.NET and I am trying to create thumbnails from .jpg
files (my travel pictures) to
post on a website. I want to create an executable that I can put in a
directory containing my jpg images which will create the thumbnails with a
"-t.jpg" extenstion. I found this code below which will create a thumbnail from a specified file, "randomphoto.jpg".

Sub Thumbnail()
Dim myCallback As System.Drawing.Image.GetThumbnailImageAbort
Dim myPtr As IntPtr
Dim myPic As New Bitmap("E:\randomphoto.jpg")
Dim myThumb As System.Drawing.Image = myPic.GetThumbnailImage(100, 100, myCallback, myPtr)
myThumb.Save("E:\mythumb.jpg", System.Drawing.Imaging.ImageFormat.Jpeg) End Sub

How can I alter this code to pick out any .jpg file in the current directory and create a thumbnail. Do I use a looping structure to read each file and run the above module? Any help in pointing me in the right direction
appreciated.
James

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John | last post by:
I am trying to create thumbnails from 2500 pictures. But I always get a Maximum execution time of 30 seconds exceeded" at the statement with the method with imagejpeg or imagedestroy after...
1
by: bob4roxio | last post by:
Is there any better quality method for creating resized images? I'm using imagecreatetruecolor and imagecopyresampled and making sure my imagejpeg quality is set at 100 but the client I'm writing...
4
by: sepgy | last post by:
Can anyone help me to use a python to create an HTML photo gallery generator. When it's finished, it will be able find all the picture files (i.e. .jpg, .gif. .png files) in any given folder on the...
0
by: Ken | last post by:
Hi all: I have created a vb.net service that watches a directory and when an image is placed in the directory a thumbnail of the image is created. The problem I am having is a...
3
by: James | last post by:
Hi, I'm a newbie to VB.NET and I am trying to create thumbnails from .jpg files (my travel pictures) to post on a website. I want to create an executable that I can put in a directory containing...
1
by: David Lozzi | last post by:
Hello, I'm wondering whats the best method to use for displaying several photos' thumbnails. One method I know is to dynamically resize the photo at the time the page is loaded. What does this...
2
by: Duane Phillips | last post by:
On image upload, I would like to save the image and also auto-create a right-size image for faster browsing, and also a thumbnail for indexes, so that slower connections do not have to wait for the...
8
by: ctiggerf | last post by:
I was hopeing someone could help me out here. Been stumped on this one all day. This function 1. Checks uploaded files. 2. Creates two resized images from each (a full size, and a...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.