Introduction
mg2 is a python application that allows you to build a complete web
site in only ONE command. Just select the directory where your
pictures resides; the layout of your pages are defined in the plugins.
More simple, it's difficult.
Despite such simplicity, mg2 have lot of functionalities : adding
comments, adding dates, ...
mg2 is heavily based on a very good application :
mt2
After a discussion with Jesse Pavel, creator of mt2, it appears that the
modification I've made differs from the original goals of mt2.
that's why mg2 was created.
Installation
mg2 requires Python 2.2 or higher and
PIL (Python Image
Library).
Download
mg2
Unzip the zip file, and execute mg2 directly or via the command :
python mg2.
Lots of configuration options exists (see below), but in a first trial
the default values should work.
mg2 was tested on Windows machines and on Linux machines, but should
work too on Mac machines and other Unixes.
Like for mt2, mg2 is distributed as two files, makethumb2.py and mg2,
and a plugins directory.
mg2 is a small driver file that tries to determine what environment it
is in, and then imports and invokes makegallery2. You should set the
MG2SCRIPTDIR environment variable to the directory that contains
makegallery2.py and the plugins subdirectory.
But, due to the functionalities added in mg2, mg2 can ONLY support PIL.
Command-line arguments
Few number of arguments differs from the original mt2.
Usage: mg2 [options]
Options:
-h or --help show this message
-ts <max thumbnail
size> (100)
-rw = max resized widths
(width for landscape pictures,width for portrait pictures)
(600,600)
-d <thumbnail
directory> (mg2_thumbnails,mg2_gallery,mg2_resized)
-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>
-g <group file name>
-hi <hide file name>
-C <comment file name>
-D <date file name>
-df = Date format
-H <header file name>
-T <trailer file name>
-t <title string> ("Picture Album")
-hr <header string> ("Picture Album")
-tr <trailer string> ("<font ...>Generated by
mg2</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)
-nd = inhibit the display of dates next to the pictures
-nf = inhibit the display
of file name 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
I've highlighted the arguments that are not like mt2 propose.
I propose you to read the excellent pdf file that describe mt2
arguments, except fot the following :
-ts : this option is excatly like -s in mt2
- rw : This let you the possibility to resize your pictures to let them
fit (normally reduce the size) an usual html page. This parameter
ask 2 values. The first one is for landscape pictures, the second
is for portrait file. mg2 will resize the pictures by keepong the ratio.
- d : directory names to store the thumbnails resized pictures, the
html file generated and the html resized pictures.
-nf : allows you to not display the picture' file name.
Resource file
Like for mt2, you can store your prefered options in a mt2rc 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 mg2. Also, there is a global resource file, ~/.mg2/mg2rc, 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 read the mt2.pdf filethat shows you a table
with the correspondance between arguments and directives. The format of
the resource le is a series of key=value pairs, one per line.
For the new/updated options, the key words are :
- the key word
max_size for
the argument -ts
- the key word
resized_widths
for the argument -rw
- the key word
thumbnail_dir
for the argument -d
- the key word
show_file_name for the argument -nf
Customization files
The customization files are exactly like defined in mt2.
mg2 has not bring new functionalities about those specific
customizations aspects.
The files that one can use to customize the order in which mg2 displays
images, and the comments or headings that it writes among them, are the
crux of generating interesting albums. I discuss the comment file,
group file, date file, hide file, and list file.
Customization file
|
Description
|
arguments
|
comment file
|
Allows you to add a small
comment under each pictures on the Thumbnail web page.
|
-C
|
group file
|
Allows you to group a small set
of pictures.
|
-g
|
date file
|
Allows you to put some specific
date under the each pictures on the Thumbnail web page.
This date will follow the date format defined with the arguments -df or
key word date_format
|
-D
|
hide file
|
allows you to no display
pictures on the Thumbnail web page.
|
-hi
|
list file
|
This flag allows one to give the
name of a list file on the command line.
|
-l
|
plugins
Due to the number of modifications on the mt2 source code, the plugins
of mt2 are not compatible with mg2.
I will adapt them in the futur.
Samples
Some samples will follows.