Atalasoft's 31 Apps in 31 Days

Batch Thumbnails

This application is a command line tool for generating thumbnail images.  To use it, unzip the executable and run it from a command prompt.  The typical usage is:

thumbnailer /maxwidth width /maxheight height folder1 folder2 folder3

Thumbnailer will open every image in every folder supplied and will create a thumbnail image is the same proportions as the original image, but will not exceed the maximum width or height.

By default, output thumbnails will be put into the same folder as the original image.  If the original image is named originalname.ext, the output thumbnail will be named tnoriginalname.jpg.  If tnoriginalname.jpg exists, it will not be overwritten.

thumbnailer needs at least one folder to operate on, but it can accept any number. 

If you omit maxwidth or maxheight, they will be 64 by default.

The complete set of options are as follows: 

  • /nobanner - when this option is present, thumbnailer will not print a banner message to the error output stream.
  • /prefix thumbnailprefix - sets the prefix to use on output files.  The default value is tn.  Output files will be named thumnailprefixoriginalfilename.jpg
  • /suffix thumbnailsuffix - sets the suffix to use on output files.  The default value is the empty string.  Outputfiles will be named originalfilenamethumbnailsuffix.jpg
  • /maxwidth width - sets the maximum width for an output thumbnail
  • /maxheight height - sets the maximum height for an output thumbnail
  • /outputfolder folder - puts all thumbnails from all original folders into the specified output folder.  The default action is to put them in the same folder as the source images
  • /overwritethumbs - if present, this options will cause existing thumbnails to be overwritten, otherwise existing thumbnails are ignored.
  • /doprefixedfiles - if present, this option will cause files that start with the thumbnail prefix to be turned into thumbnails.  By default, they are ignored.
Options can start with / or - to make both DOS users and UNIX users happy.

Inside the Source Code

The source code is very simple - most of the code handles command line arguments.  If you look at the Main method, you will see that the app makes a single eponymous object, processes arguments, prints a banner, then makes thumbnails.

The method MakeThumbs with no arguments loops over a list of folders and delegates the task of creating thumbs to another flavor of MakeThumbs which loops over each image file in a folder, makes a thumbnail image, then writes out the file, if appropriate.

MakeThumb reads in an image, turns it into a thumbnail using a ResampleCommand object then returns the thumb.


Download executable

Download source

Published Sunday, May 04, 2008 11:35 AM by Steve Hawley



Atalasoft's 31 Apps in 31 Days : 31 Apps Gallery said:

May 4, 2008 9:03 PM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

May 7, 2008 1:16 AM
Anonymous comments are disabled