PHP Thumbnail Image Gallery Script

This is an image gallery script that allows you to simply upload new full sized images in FTP and the script will automatically create the thumbnails for those images and add those images to a paged thumbnail gallery suitable for browsing.

Version 1.2.0 and onward is released under GNU General Public License. Basically this means you are free to use the script, modify it, and even redistribute versions of your own under the same license.

Open gallery.php and scroll down to about line 30 and look for $config['size']. Set this to the maximum width or height you want your image thumbnail to be.

On the next line in the $config['imagequality'] set this to the JPEG quality you would like your thumbnails to be. I recommend you keep it set to 70

$config['rows'] and $config['cols'] are the number of rows and number of columns of thumbnail images you want shown on each page

$config['maxShow'] is the number of page numbers to show at one time. for instance if you have 100 pages of images, you can set this to only show the page numbers of the 10 pages close to where you currently are

$config['fulls'] is the relative path to the full size images located on your server. Include the trailing slash. example: $config['fulls'] = "photos/";

$config['thumbs'] is the relative path to where you want the thumbnail images to be stored. Include the trailing slash.

The entire gallery table is controlled by the CSS settings you'll find toward the bottom of the gallery.php file. I tried to comment each specific part of the CSS and what it controls so you can easily change the look of the gallery without actually having to actually edit any of the PHP.

Lightbox Support (OPTIONAL)

I've had multiple people want to know how to make this gallery work with the Lighbox script or telling me that they modified it (which is great!) themselves. While the above gallery script does not come with Lightbox support, modifing it to work with Lightbox requires very minor changes.

Modern cameras often save all images in landscape (horizontal) mode. When taking a portrait (vertical) picture, the camera still saves the picture in landscape mode but it will add an EXIF tag that identifies the orientation of the picture.

PHP's GD2 library does not read that orientation EXIF tag so you end up with a landscape thumbnail that represents the actual image.

There is likely a way to either (1) read the tag and correctly adjust the thumbnail, or (2) rewrite the necessary tag into the thumbnail using PHP. However, that addition is beyond the amount of time I want to donate into a project I no longer use myself.

You are hitting the RAM limit that PHP is allowed to use for your server. Most likely because PHP is trying to process an image too large in size for it to load into memory and create a thumbnail. Some hosts allow you to overwrite this limit. At the top of the PHP file that is having problems, putting:ini_set("memory_limit","128M"); might work. You can also try creating a /public_html/php.ini file with this value:memory_limit = 128M
If that doesn't work, try creating a /public_html/.htaccess file with this value (if that file already exists, just add this line to it):php_value memory_limit 128M

If none of those work, you'll need to either manually create the thumbnail and upload it to your thumbnail directory, or resize the original down to something smaller that the script can handle (this might be a good idea anyway so a visitor doesn't spend too long loading any full sized images).

Currently I'm using the gallery.php file and PHP Thumbnail script version 1.2. I want to change the order to which each JPG file is loaded with the newest on Page 1 and the oldest on Page 100 etc. Is there any way to modify the gallery.php file to do this.

If you want to keep the current page listings, but add a "Show All" link, look for the line:$imagelist = GetFileList($config['fulls']);and under it add:if(!empty($_GET['showall']) && count($imagelist)>0) $config['rows'] = ceil(count($imagelist)/$config['rows']);

Then in your HTML, add your link to show all:<a href="gallery.php?showall=true">Show All</a>

I'm using your script as thumbnails creator for my webcam images. My webcam shoots a photo every 3 minutes and then store all the photos in a folder where I use your script to create thumbnails. Every 24 hours the photos are overwritten with the same image name. Problem is that for the first 24 hours thumbnails match the real photos, while after 24 hours all the photos you see in thumbnails are the old one while if you click on it it shows the real updated one. Is there a way to have all the thumbnails always updated with the last photos shot?

You can show the file name under the thumbnail by changing the line:echo '<img src="'. $config['thumbs'].$imagelist[$i] .'" alt="'. $imagelist[$i] .'">';toecho '<img src="'. $config['thumbs'].$imagelist[$i] .'" alt="'. $imagelist[$i] .'"><br/>'.$imagelist[$i];

I have my images folder with about 100 images in there from my iPhone. All named "IMG_####.JPG". It was only showing the first 3 images and no pagination. I removed one of the images shown, and it now only shows 2 images.
Is there a problem with the filenames?
Also I'm not familiar with the "Oops()" function...?