Usage

PHP Mini Gallery is very simple to use. You won't need to have any PHP skills.

First, you have to create a directory for the gallery. Make sure that the script is allowed to create files in this directory.

Now you upload all your pictures into this directory. The only image formats allowed are JPEG, PNG and GIF. The file names need to have a correct suffix, and must not start with th_, because it is reserved for the thumbnail files. The PHP Mini Gallery shows the pictures in alphabetical order of their file names. I got myself used to name the pictures 01.jpg, 02.jpg and so on, but this is not required.

If you want to add a caption to a picture (e.g. a description of the picture's content), you can place the text in another file, which is named like the picture this caption will belong to, but has an additional .txt suffix attached. Example: the caption file for the picture 04.jpg would be named 04.jpg.txt.

Finally you have to place the PHP files index.php and template.php from the PHP Mini Gallery archive into that directory. And that's all!

If you invoke the page with your browser, you'll first see an index print of all pictures' thumbnails. At the first invocation, the thumbnails will be created automatically, and will be stored in files with an appropriate file name, but th_ attached before, and .jpg behind the file name. Example: the thumbnail of picture 04.jpg is named th_04.jpg.jpg. The double jpg suffix is intentional. This first invocation could take a while until all thumbnails are created, and may even time out. For subsequent calls, the thumbnail files will be used though, so you will receive the index page much faster. PHP Mini Gallery will detect if you have modified a picture, and will automatically re-create its thumbnail image.

If you click on a thumbnail, you will get the full size picture. Starting from there, you can see the next picture by clicking into the current picture, or you can go forward and back using the navigation links.

Configuration

At the beginning of the script index.php, you will find a few configuration parameters. PHP Mini Gallery already has reasonable default values, so you usually won't need to change them unless you really want to change them.

  $CONFIG['thumb.width']    = 100;      // Thumbnail width (pixels)
  $CONFIG['thumb.height']   = 100;      // Thumbnail height (pixels)

This is the maximum dimension of thumbnail pictures. While scaling, PHP Mini Gallery will take care to keep the aspect ratio of the picture.

  $CONFIG['thumb.scale']    = 'gd2';    // Set to 'gd2', 'im' or 'gd'
  $CONFIG['tool.imagick']   = '/usr/X11R6/bin/convert';  // Path to convert

Here you will set the scaling tool.

  • gd2 selects the GD2 library, which is installed in most of the recent PHP setups. It will result a good quality without any installation hassles, and thus is the recommended setting.
  • im uses ImageMagick for scaling. You have to set the path to the convert tool in 'tool.imagick'! Use this if GD2 is not available.
  • gd uses the legacy GD library, which should be available in almost all PHP installations. The quality is quite poor, though, so you should only take this one if you have no other choice.

Note: You must set the absolute path to ImageMagick's convert tool. If you are in the unlucky situation to be confronted with a Windows server, also remember to double the backslashes (e.g. 'C:\\path\\to\\convert.exe').

  $CONFIG['index.cols']     = 6;        // Colums per row on index print

The number of picture colums at each row of the index print.

  $CONFIG['template']       = 'template.php';   // Template file

Path to the template file, which is used for HTML generation. If you want to use a common template file for several galleries, you can also set the path to this file here. The gallery will then only require the index.php file in each directory.