HEAD PREVIOUS

1  Introduction

This manual describes the mt2 (that is, make-thumbnails 2) program, which is designed to make it easy for one to create and maintain large numbers of pictures in HTML photo albums, along with descriptions, titles, grouping, and a lot of other features that I will eventually explain. I used to write that mt2 is not a program for Quiche-Eaters1, but starting with version 1.2, it supports output plugins with which you can generate pages as fancy or colorful as you would like; however, its main focus is still on the meat and content of the albums.
First, I'll present an overview of what you need to run mt2, and how to actually invoke the program, along with all of the command-line arguments it accepts. Then, in the next section, I'll go into the files with which one can customize albums, and which are central to the really sweet features of the program. Finally, I'll describe how to use the output plugins ("themes" if you will) that come with mt2, and how you can write your own, if you're so inclined.

1.1  Installation

To run mt2, you'll need Python 2.2 or higher, and the convert program from the ImageMagick package; alternately, if you have the Python Imaging Library installed, mt2 will use it instead of starting an external program. Also, mt2 was written on Linux, and works with any Unix-like operating system (including OS X)---I've also recently tested it on Windows with PIL, and maybe with some tweaking it could run on the Mac as well. You can download python from http://python.org/, ImageMagick from http://www.imagemagick.org/, and the Python Imaging Library from http://www.pythonware.com/products/pil/.
Mt2 itself is distributed as two files, makethumb2.py and mt2, and a plugins directory: mt2 is a small driver file that tries to determine what environment it is in, and then imports and invokes makethumb2. You should set the MT2SCRIPTDIR environment variable to the directory that contains makethumb2.py and the plugins subdirectory; and if the convert program is called something else than convert on your system, set MT2CONVERT to the name of the program you want to use. If you are on a Unix-like system, edit the mt2 file and change the first line from "#!/usr/bin/python2 -O" to point correctly to your Python binary; if you are on Windows, you'll probably want to run the program with the command line "python <path to mt2>/mt2".

1.2  Invocation

Here I will describe how to run the program, and go over the command-line arguments that it accepts. Once you have mt2 set up as above, you run it by typing mt2, along with any options you wish to pass it. In addition to command line arguments, mt2 can take configuration commands from a resource file that is specific to each directory thumbnailed. We'll cover these resource files after we present the command-line flags. A quick summary of all the options is taken directly from the output of mt2 itself:
Usage: mt2 [options]
  Options:
   -h or --help  show this message
   -s <max thumbnail size>  (100)
   -d <thumbnail directory> ("thumbnails")
   -a <base album name> ("00_album_images")
   -ni <base imageless album name> = ("00_album_noimages")
   -ani <name for both albums> ("00_album")
   -l <list file name>
   -i <include file name>
   -g <group file name>
   -hi <hide file name>
   -C <comment file name>
   -D <date file name>
   -H <header file name>
   -T <trailer file name>
   -t <title string> ("Picture Album")
   -hr <header string> ("<h2>Picture Album</h2>")
   -tr <trailer string> ("<font ...>Generated by mt2</font ...>")
   -n <number of images per album> (30)
   -G <glob pattern of items to thumbnail> (*.jpg,*.jpeg,etc.)
   -b force the inclusion of the ".." (back) folder.
   -f = force thumbnail generation, even if the .nothumbnail file exists
   -ft = generate a new album even if the directory appears up to date
   -R = walk directories recursively, generating thumbnails
   -np = do not prune unneeded thumbnails from the thumbnail directory (default on)
   -fp = force pruning when it otherwise would be disabled
   -nd = inhibit the display of dates next to the pictures
   -Ii = in each directory, symlink index.html to the image album
   -Ini = in each directory, symlink index.html to the noimage album
   -sn = list the pictures in alphabetical (ASCII, actually) order
   -sa = list the pictures in order of recency, oldest first (default)
   -sd = list the pictures in order of recency, newest first
   -r <rc file> = use an alternate resource file.
   -op <output plugin> = choose an alternate output plugin. ("plainhtml")
   -pc <configuration string> = pass a configuration string to the output plugin.
   -lp = list available plugins

By default, mt2 will generate albums of all the JPEG files in the current directory and stop. Sometimes that is what you want, but I know that other times you will want to make phat albums, and that is where all the options come in; and so, here is a detailing of each flag, along with some information about how the program works.
-h, --help
This, if it weren't obvious, prints out the help text that you see above.
-s
Normally, each thumbnail in the HTML album is confined to a 100x100 box, but you can change the size by using this flag with a new size, for instance -s 40 to make tiny little thumbnails.
-d
Mt2 by default creates a subdirectory named thumbnails for each directory that you want to thumbnail. You can change the name using this flag.
-a
The HTML albums are named by a combination of a prefix and a number. For instance, if one has three albums in a directory, they will by default have the names 00_album_images-00.html, 00_album_images-01.html, and 00_album_images-02.html. To change the "00_album_images" part of these names, use the -a flag with the new name.
-ni
This flags works exactly as the -a flag, except that it affects the text-only albums, which are by default named with the prefix 00_album_noimages.
-ani
With this flag, you can set the base name for both the image album and the text only album at the same time. If you use -ani base, the albums will have the prefices base_images and base_noimages, respectively.
-l
Mt2, instead of reading filenames itself from the directory, can take them from a "list file", a procedure that I will discuss in detail in the next section. This flag allows one to give the name of a list file on the command line.
-i
Using an "include file" allows you to keep the names of the pictures you wish to process in a file, instead of constructing an elaborate glob to include them all. See the paragraph on include files in the next section for more information.
-g
Group files, which can be given with this flag, are a way of telling Mt2 that one wants certain files to appear next to each other in the albums, though they might not otherwise do that with the given sort order---they too will be discussed in the next section.
-hi
"Hide files" will be discussed later, but briefly, allow one to tell mt2 not to thumbnail certain files. They are specified using this flag.
-C
Each picture can have a comment printed under its name in the album, and these comments are stored in a "comment file", which can be given with this flag. We'll talk about comment files in detail in the next section.
-D
You can override the date displayed in the thumbnail albums for each picture with specific dates of your own, using a "date file", indicated by this flag---in the next section, I give more detail about this type of file.
-H
One might want a potentially complicated header to be inserted into each album, and with this flag one can specify an HTML file to fill this role.
-T
This parallels the -H flag, except the trailer file will be inserted at the end of each album.
-hr
If the header that you want at the top of each album is fairly simple, you can just pass it on the command line using this flag. For instance, -hr '<h1>Big Ugly Photos</h1>'.
-tr
This flag is just like -hr, except that it works for the trailer.
-n
If you have many images in a directory, mt2 splits them among a number of albums to help with navigation and load times. By default, it puts 30 images per album, but you can change that using this flag.
-G
Normally, mt2 thumbnails all the JPEG files in the current directory, using the wildcard pattern of *.jpg,*.JPG,*.jpeg,*.JPEG. You can specify a different pattern with this flag; for instance, to thumbnail all GIFs instead, use the argument -G '*.gif,*.GIF' (note the single quotes around the wildcards).
-b
When processing directories recursively, mt2 includes the ".." (back) directory in the list of folders; but when operating non-recursively, it doesn't include it---this option forces the inclusion of "..", regardless of the mode.
-f
If there is a directory for which you do not want thumbnails generated, you can create a file named .nothumbnail in it; normally, if mt2 detects such a file, it will abandon its attempt to create albums; however, if you want it to thumbnail the directory anyhow, use this flag.
-ft
When mt2 is working recursively (see the -R switch below), it first checks if each directory seems to have changed since it last thumbnailed it; if it hasn't changed, mt2 skips it. This flag causes mt2 to create new albums regardless of whether it thinks the old albums are up to date.
-R
Mt2 usually works on just the current directory, but by using this flag, you can tell mt2 to operate not only on the current directory, but also on all its subdirectories. There are two types of directories mt2 skips, though: directories that contain a .nothumbnail file, and directories that are named the same as the thumbnail directory, so that it doesn't accidentally make thumbnails of thumbnails.
-np
After creating an album, mt2 usually checks if there are any extra thumbnail images lying around in the thumbnail directory, and if so deletes them. This flag prevents it from pruning these extraneous images.
-fp
Some configuration options cause pruning to be disalbed; by specifying -fp, you can tell mt2 to force pruning.
-nd
In the albums, next to the picture names, mt2 usually displays the date that the picture was taken (or uploaded). Sometimes you want to disable the display of dates in the albums, and this flag does that.
-Ii
For each directory that mt2 thumbnails, it can create a symbolic link from index.html to the first album file, so that when someone looks at the directory from their browser, they are served the image album instead. This will work only on Unix and its kin.
-Ini
This is the same as -Ii, except the link will be made from index.html to the text-only album.
-sn, -sa, -sd
The pictures in the albums can be sorted by name (-sn), by ascending date from oldest to newest (-sa), or by descending date from newest to oldest (-sd). The default is by ascending date.
-r
In addition to taking configuration options from the command line, mt2 can read a resource file to get options, and with this flag, you can specify an alternate file from which to read customizations. Mt2 by default searches for a file named .mt2rc, and if that is not present, then .make-thumbnailsrc, for historical purposes.
-lp
This switch will have mt2 examine its plugin directory and list the plugins that it finds there.
-op
Mt2 uses an output plugin to actually write the HTML (though theoretically the plugin could write whatever format of file it wishes, perhaps a PDF) albums, and one can choose which to use with this switch. The default is plainhtml. See the section on plugins for more information abou this.
-pc
You can pass configuration options to the output plugin, in addition to any options that the plugin reads from its personal files, using this switch. As the argument to -pc, pass a string of the format "key:value,key:value,...", where the keys and values will have meaning dependent on the plugin you select. For example, with the darkhtml plugin, to be discussed later, you can use this switch in the line, -pc "columns:3,data_url:http://host.com/darkhtml/".

1.3  Resource File

In each directory, you can keep a `resource file' so that you don't have to type all of your options on the command line every time you invoke mt2. Also, there is a global resource file, ~/.mt2/mt2rc, that will be read before processing any directory-specific resource files. The directives that you can use in the resource file correspond to command line options, so I'll just present a table, Table 1, showing which directives correspond to which options. The format of the resource file is a series of key=value pairs, one per line; here is an example file:
 sample .mt2rc
sort-order=date_ascending
header-string=<h1>Hot Beach Babes</h1>
glob-pattern=beach*.jpg

Table 1: Resource file directives.
Directive Command Line Switch Example
sort-order -sn (name) sort-order=date_ascending
-sa (date_ascending)
-sd (date_descending)
album-name -a album-name=00_vacationpics
no-image-album -ni no-image-album=00_vacationpics_textonly
both-album-names -ani both-album-names=june_pictures
thumbnail-directory -t thumbnail-directory=thumbs
list-file -l list-file=picturelist.txt
include-file -i include-file=vacation-pics.txt
group-file -g group-file=groups.lst
hide-file -hi hide-file=hidden-pics.txt
header-file -H header-file=intro.html
trailer-file -T trailer-file=credits.html
title-string -t title-string=Florida Pictures
header-string -hr header-string=<b>My Phat Photos</b>
trailer-string -tr trailer-string=<h2>Taken by Magnus</h2>
comment-file -C comment-file=comments.txt
date-file -D date-file=special-dates.txt
glob-pattern -G glob-pattern=*.jpg,*.gif,*.tiff
force-back -b force-back=true
max-size -s max-size=150
num-images -n num-images=20
date -nd date=no
prune -np, -fp prune=yes
output-plugin -op output-plugin=darkhtml
plugin-config -pc plugin-config=columns:5

HEAD NEXT



File translated from TEX by TTHgold, and styletth.py.