Image Gallery
What is it?
This is a simple and easy to use script providing an image gallery. The images are displayed as thumbnails or as slideshow. The script can also handle several galleries. The highlight of this gallery is the usage of the GD-library to render dropshadows for thumbnails and slideshow images.
Features
- easy to use
- works with *.png, *.jpg and *.gif files
- single or multiple galleries
- rendering dropshadows with GD-library
- rendering borders with GD-library
- caching all generated files (leaving original images untouched)
- appearance can be customized with CSS
- valid xhtml1.1
Requirements
- PHP-enabled webserver
- PHP compiled with GD
- write access in the gallery-folder to cache generated images
Warnings/Hints
Imagemainipulation takes lots of system resources!
Normaly on a productiv webserver these resources are stictly limited for the PHP interperter. This can cause that the image generation fails because of memory or execution time limits.
In this case you have to modify your PHP configuration. Increase the values for these parameters in your php.ini :
max_execution_time = 30
memory_limit = 8M
A 1600x1280px image needs round about 15 MByte of Memory. When the script renders all thumbnails and slideshow images at once the execution time can raise up to hours for big galleries. So you have to experiment to find out the right values for your needs. Don't forget to restart your webserver to apply the changes!
If you can't modify the PHP configuration for your webserver, you have to install one on your desktop. I suggest apachefriends.org. It is easy to install on all plattforms and comes with everything you need for webdevelopment.
Then you can generate all images on your local maschine and upload everything to your webserver. Anyhow I suggest this way for big galleries to prevent an overload on the server.
Apology
This script is good example for bad php-coding. The usage of global variables in this script is a perfect explaination for why you should avoid to use them. But I only wanted to test the posibilties of the GD-functions in PHP, so the script is grown and not clean implemented.
So you have my apologies for this. Enjoy the nice looking images and ignore the ugly code which created this beauteousness.
scnr ;-)
Download
Screenshot
Documentation
Usage
This script is very easy to use. It generates galleries from the given directories (which should contain images of course).
The generated slideshow images are stored in the folder .modified and the thumbnails are stored in .thumbs. So make sure your web server has the right permissions to write files in your gallery folder.
Normaly thumbnails and slideshow images are generated when they are requested the first time. But you can automatize this procedure (and generate all images at once) by doing the following steps:
- call the script in your webbrowser
- choose the gallery you want to generate all images for
- append the following string to the URL and recall the script
&action=generate_all
This is especially useful when you generate all images on your desktop.
Configuration - Gallery Settings
In this section all main configuration variables are explained.
$width
Defines the width of the main frame.
IMPORTANT: Because it infuences the size of thumbnails and slideshow images, changing this value causes that all images have to be regenerated!
$thumbnails_per_row
How many thumbnails you want to have in every row.
IMPORTANT: Same as for $width.
$thumbnail_indexing
Decide if you want all thumbnails to be displayed at once (FALSE), or indexed (TRUE). For big galleries I suggest the indexed mode.
$thumbnails_per_page
How many thumbnails you want to have on every page. (This parameter is only relevant when thumbnail indexing is enabled - see $thumbnail_indexing above).
$thumbnail_filetype
Choose the format for thumbnails (png or jpg).
$slideshow_filetype
Choose the format for slideshow images (png or jpg).
$multipleGalleries
When you have only one gallery set this parameter to FALSE.
$galleries
This is an associative array. The key is the name for this gallery and the element is the relative path to the folder containing the images you want the gallery for.
If you have set $multipleGalleries to FALSE only the first entry is noticed.
$link_original_image
Decide if the slideshow items should be a link to the orginal image.
Configuration - Image Settings
With the following parameters you can influence the look of the generated images. You have to experiment with these values, because most of them depends on the choosen values for $width and $thumbnails_per_row
IMPORTANT: Always delete the generated images in the folders .modified and .thumbs when you change anything here. Of course this means that everything has to be regenerated!
This section has three parts:
- settings for slideshow images
- settings for thumbnails
- colors
The first two are mostly identical - that's why I only explain the one for images. Third section defines the colors, which are implemented as arrays containing RGB-values.
$image_margin
Defines the margins from the main frame border.
HINT: This parameter ist not availible for thumbnails.
$image_border
Decide if the images shold have a border.
$image_dropShadow
Decide if the images shold have a dropshadow (I am sure you want :-) ).
$image_offset_x
X-offset of the original image in the generated one.
$image_offset_y
Y-offset of the original image in the generated one.
$image_dropShadow_scale
Scales the size of the dropshadow.
$image_dropShadow_offset
Defines the offset for the dropshadow.
$image_dropShadow_blurRadius
Defines the blur radius for the dropshadow.
HINT: This parameter should not be greater then 46 pixel and not greater then $image_dropShadow_offset.
$background_color
Defines the backgroundcolor for your gallery.
$border_color
Defines the color for the border (when $image_border is enabled).
$dropShadow_color
Defines the core color of the dropshadow.
HINT: This color has to be darker then the backgroundcolor. Otherwise the gradient calculation might fail.

