469,631 Members | 1,147 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

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 1535
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by bob4roxio | last post: by
4 posts views Thread by sepgy | last post: by
reply views Thread by Ken | last post: by
3 posts views Thread by James | last post: by
1 post views Thread by David Lozzi | last post: by
2 posts views Thread by Duane Phillips | last post: by
8 posts views Thread by ctiggerf | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.