473,395 Members | 1,516 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,395 software developers and data experts.

how to produce thumbnails

hi,
I have a whole lot of pictures needed to transform to the thumbnails to
display on the web, it there any easy to do?

Thanks.
Nov 18 '05 #1
5 1244
Here's some code I've been playing around with. It creates square thumbs,
but could easily be modified to create proportional...

private void CreateThumbnail(string pathToFullSizeImage, string
pathToThumbnailImage, int sizeToCreate) {
try {
int iWidth = 0;
int iHeight = 0;
string strFilename = pathToFullSizeImage;
int dotPlace = strFilename.LastIndexOf(".");
string fileType = strFilename.Substring((dotPlace + 1),
(strFilename.Length - (dotPlace + 1))).ToUpper();

if (sizeToCreate == 1) {
iWidth = 80;
iHeight = 80;
}
else {
iWidth = 130;
iHeight = 130;
}

System.IO.FileStream fs = new System.IO.FileStream(pathToFullSizeImage,
System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.Drawing.Image objThumbnail =
System.Drawing.Image.FromStream(fs).GetThumbnailIm age(iWidth, iHeight, null,
IntPtr.Zero);
// DO NOT USE THE FOLLOWING LINE (in place of the previous line) because
Image.FromFile() keeps the file open. This is why we open the file via a
stream - a stream can be closed.
// System.Drawing.Image objThumbnail =
System.Drawing.Image.FromFile(strFilename).GetThum bnailImage(iWidth,
iHeight, null, IntPtr.Zero);

// Set the ContentType correctly
if (fileType == "JPG" || fileType == "JPEG") {
objThumbnail.Save(pathToThumbnailImage, ImageFormat.Jpeg);
}
else {
objThumbnail.Save(pathToThumbnailImage, ImageFormat.Gif);
}

objThumbnail.Dispose();
fs.Close();

}

catch (Exception ex) {
if (!(ex is OOPS.DalException)) {
OOPS.WriteErrorInfo(ex, "");
}
}
}
"Daniel" <so*****@yahoo.com> wrote in message
news:opsa62m7naxo301l@dev-02...
hi,
I have a whole lot of pictures needed to transform to the thumbnails to
display on the web, it there any easy to do?

Thanks.

Nov 18 '05 #2
Daniel wrote:
hi,
I have a whole lot of pictures needed to transform to the
thumbnails to display on the web, it there any easy to do?

Thanks.


How about "Easy Thumbnails" (freeware) from
http://www.fookes.com/

<g>

-- Mark
Nov 18 '05 #3
Felipe, i really appreciate your help.
On Thu, 15 Jul 2004 13:01:10 -0700, Felipe <be***@musicalfruit.com> wrote:
Here's some code I've been playing around with. It creates square thumbs,
but could easily be modified to create proportional...

private void CreateThumbnail(string pathToFullSizeImage, string
pathToThumbnailImage, int sizeToCreate) {
try {
int iWidth = 0;
int iHeight = 0;
string strFilename = pathToFullSizeImage;
int dotPlace = strFilename.LastIndexOf(".");
string fileType = strFilename.Substring((dotPlace + 1),
(strFilename.Length - (dotPlace + 1))).ToUpper();

if (sizeToCreate == 1) {
iWidth = 80;
iHeight = 80;
}
else {
iWidth = 130;
iHeight = 130;
}

System.IO.FileStream fs = new System.IO.FileStream(pathToFullSizeImage,
System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.Drawing.Image objThumbnail =
System.Drawing.Image.FromStream(fs).GetThumbnailIm age(iWidth, iHeight,
null,
IntPtr.Zero);
// DO NOT USE THE FOLLOWING LINE (in place of the previous line)
because
Image.FromFile() keeps the file open. This is why we open the file via a
stream - a stream can be closed.
// System.Drawing.Image objThumbnail =
System.Drawing.Image.FromFile(strFilename).GetThum bnailImage(iWidth,
iHeight, null, IntPtr.Zero);

// Set the ContentType correctly
if (fileType == "JPG" || fileType == "JPEG") {
objThumbnail.Save(pathToThumbnailImage, ImageFormat.Jpeg);
}
else {
objThumbnail.Save(pathToThumbnailImage, ImageFormat.Gif);
}

objThumbnail.Dispose();
fs.Close();

}

catch (Exception ex) {
if (!(ex is OOPS.DalException)) {
OOPS.WriteErrorInfo(ex, "");
}
}
}
"Daniel" <so*****@yahoo.com> wrote in message
news:opsa62m7naxo301l@dev-02...
hi,
I have a whole lot of pictures needed to transform to the thumbnails
to
display on the web, it there any easy to do?

Thanks.



Nov 18 '05 #4
A good pair of thumbnail clippers.

;-)

Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Daniel" <so*****@yahoo.com> wrote in message
news:opsa62m7naxo301l@dev-02...
hi,
I have a whole lot of pictures needed to transform to the thumbnails to
display on the web, it there any easy to do?

Thanks.

Nov 18 '05 #5
Now I know why you're an MVP : )


"Kevin Spencer" <ks******@takempis.com> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
A good pair of thumbnail clippers.

;-)

Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Daniel" <so*****@yahoo.com> wrote in message
news:opsa62m7naxo301l@dev-02...
hi,
I have a whole lot of pictures needed to transform to the thumbnails to display on the web, it there any easy to do?

Thanks.


Nov 18 '05 #6

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

Similar topics

5
by: Lemming | last post by:
Hi, I'm putting together a website for a local estate agent. One of the things they want to do is upload property descriptions/prices/etc. plus a picture of the property which is for sale.
5
by: Ken | last post by:
I am in the process of designing my first web-site, and am having a problem with my picture gallery. My thumbnails are all different sizes, I would like them to be one size. The manual does not...
6
by: c d saunter | last post by:
Greetings All, In Widows Explorer there is a thumbnail view, where you see images as thumbnails. Applications such as MS Office and OpenOffice, when installed, cause their respective filetypes to...
4
by: Rednelle | last post by:
Greetings all, As a newbie, using Access 2000, I would appreciate advice on the best way to include pictures. I have developed a 'Home Inventory' database which can include jpeg thumbnails of...
3
by: Vagabond Software | last post by:
I'm trying to display thumbnail images in a Listview that look more like the Windows thumbnail view. Everything is working pretty good, but my thumbnails are decidedly not like the Windows...
6
by: Rich | last post by:
Hello, I want to simulate the dynamic thumbnail display of Windows Explorer (winxp) on a form or pannel container. If I place a picture box on my container form/pannel and dimension it to the...
4
by: Barely Audible | last post by:
Guys I was wondering if it was possible to have a js file that, when the page loaded, it automatically generated a a set of thumbnails from directory of the page on the web server? Or would...
5
by: JJ | last post by:
I have a gallery-like application. (The gallery will be actually presented in Flash, but the management (cms) of the images will be in asp.net. ) My question is, is it ok to create Thumbnail...
1
by: iswar | last post by:
hi friends asp.net(2.0) c# i am trying to create an image gallery in which all the uploaded image are converted into thumbnails and i want to bind these thumbnails into gridview. and on clicking...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.