473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 1713
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.