Click here to Skip to main content
Click here to Skip to main content

Thumbnail Generator - An easy way to process thumbnails from a large amount of images

, 9 Mar 2003
Rate this:
Please Sign up or sign in to vote.
Thumbnail Generator application supporting a bunch of image file types (for both: source images and target thumbnails), fixed target image size as well as ratio calculation, and full internationalization.

Sample Image - ThumbGenerator/ThumbGenerator.png

Introduction

I have always had problems generating thumbnails from a large amount of images quickly and easily. Also standard graphic programs couldn't meet my needs - or it simply took too much time handling image after image.

Benefits

This Thumbnail Generator is qualified for generating thumbnails of images you are publishing on the Internet. Pre-generated thumbnails save you processor utilization and disk space (if you're generating thumbnails on the fly) - or user's time and money.

But also converting a large amount of images from one file format to another can be handled easily.

This project might also be an interesting starting point for Win Form rookies. Learn how forms, simple internationalization support and XML are working together! Just download the project source code, all source files are commented.

Supports

Image support

  • Different file formats (BMP, GIF, JPEG, PNG, TIFF) - for both: source images and target thumbnails
  • Self specified thumbnail image extensions
  • Preview of source images and output thumbnails (including information on width, height, ratio)
  • Fixed width, height as well as maintaining aspect ratio
  • Bilinear re-sampling

Generating a ListBox item:

/* Retrieve image to get it's infos */
Image LbxSourceImage = Image.FromFile(filesFromDialog[i]);
imgList.Images.Add(LbxSourceImage);


/* Calculate image ratio */
float Ratio=((float)LbxSourceImage.Width)/((float)LbxSourceImage.Height); 

/* Generates Listboxitem */
ImageListBoxItem lbxItem = new ImageListBoxItem(
    filesFromDialog[i].ToString()+                /* Filename */
    "\r\n"+txtWidth+LbxSourceImage.Width.ToString()+    /* Width    */
    ", "+txtHeight+LbxSourceImage.Height.ToString()+    /* Height   */
    ", "+txtRatio+Ratio.ToString(),i);            /* Ratio    */

lbxSource.Items.Add(lbxItem);

Multilingual support

Also full multilingual support for English and German language is provided. (Feel free to contribute other translations Wink | ;) )

Internationalization is managed via XML. All GUI texts are read on startup, from the application configuration file (of course the language can also be changed during a session). The project includes a collection of useful methods for processing XML documents. You can easily use them for your own applications.

The configuration file looks like:

<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE Application SYSTEM "Config.dtd">
<Application>
  <Information>
    <Name>Thumbnail Generator</Name>
    <Version>0.8</Version>
  </Information>
  <StdLanguage Type="en"/>
  <Language Type="en">
    <Text GUIRelation="btnGenerateThumb">Generate Thumbnails -->

Within the application the language information is fetched via XPath. Sample calls:

XPathDocument XPathDoc = new XPathDocument(configFileName);
XPathNavigator nav     = XPathDoc.CreateNavigator();

gbxSource.Text = XmlManager.GetValueFromXPath(nav, 
          "/Application/Language[@Type='"+
          CurrentLang+"']/Text[@GUIRelation='gbxSource']");
gbxTarget.Text = XmlManager.GetValueFromXPath(nav, 
          "/Application/Language[@Type='"+
          CurrentLang+"']/Text[@GUIRelation='gbxTarget']");

History

  • 09. March 2003: Initial release. See section "Supports"

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Christian Ballerstaller
Web Developer
Germany Germany
Experience:
- Java
- C#
- XML, XSL, PHP, ASP, ASP.NET
- Server administration
 
- ASM, Visual Basic (poor)
- Linux (poor)
 
If you have any offers, questions, or project ideas please feel free to contact me.
 
If you experience any bugs in my software, please report them.
 
Thank you.

Comments and Discussions

 
GeneralSmall error in your demo with Maintain aspect with height specified Pinmembermaildlee31-Jan-10 20:46 
Generalsending the Image to another function Pinmemberdogmatic697-Nov-07 3:43 
GeneralHere's the spanish translation and some comments Pinmemberbauersachs11-Dec-06 4:08 
Generaldelete files that add to imageList box Pinmembernazli28-Aug-06 4:22 
QuestionHELPPPPPPPPPPPPP Pinmemberseapigg16-Jul-06 7:47 
First off, great program - so easy to use and powerful.
 
I came across your program because I accidently formatted my girlfriend's camera's SD card! I was able to undelete almost all of the files, but many were incomplete. Funnily enough, the incomplete files APPEAR complete only when viewed as thumbnails in Windows, but not when actually opened. Since your program creates thumbnails, the images that it makes are 100% complete.
 
Unfortunetly, since the program generates thumbnails, the resolution is too poor to actually use the generated images, and using a larger image size just reduces quality. I was wondering if there was any way that you know of, either my altering your sourcecode or otherwise that would allow for a VERY LARGE (ie 4mp) "thumbnail" to be generated. I will be infinetly greatful for any help/insight you can give.
 
Keep up the good work, thanks.

 
SCOTT
Generaluse ratio to make images look better Pinmemberdjohnson1496-Dec-05 3:55 
GeneralI-Load - thumbnail generator free component Pinmemberzioturo3-Nov-05 1:59 
GeneralA generic error occurred in GDI+ PinmemberPaul Novelli9-Jul-05 7:11 
GeneralRe: A generic error occurred in GDI+ Pinmemberdogmatic697-Nov-07 3:25 
Questionsource of the dll?? Pinmembermistery2218-Oct-03 9:51 
GeneralCannot find file exception PinsussC# Beginner20-Apr-03 18:48 
QuestionControls library? PinmemberTodd Smith11-Mar-03 5:20 
AnswerRe: Controls library? Pinmemberperlmunger11-Mar-03 10:53 
GeneralRe: Controls library? PinmemberChristian Ballerstaller11-Mar-03 11:06 
Generalirfanview PinmemberLoneRanger10-Mar-03 22:28 
GeneralRe: irfanview PinmemberChristian Ballerstaller11-Mar-03 11:12 
GeneralRe: irfanview Pinmemberjstephenson177122-Jan-04 16:23 
GeneralRe: irfanview PinmemberTodd C. Gleason16-Nov-04 14:51 
GeneralRe: irfanview PinmemberRowland Shaw29-Dec-05 4:14 
GeneralRe: irfanview PinmemberDermot O S26-Oct-07 2:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141220.1 | Last Updated 10 Mar 2003
Article Copyright 2003 by Christian Ballerstaller
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid