. * * This script makes a photo gallery out of the images in its current directory. It is designed for pictures * which were pulled directly off of some sort of digital camera, as it samples the pictures into both thumbnail size, * and 'smaller' versions (~50k in size) which enables quicker downloading for simple browsing of the pictures. * * The full version of each picture is available from the script by simply clicking on the picture's respective 'full' link. * * Usage instructions: put this as the index to the directory which contains all the pictures. * Load the page to generate the thumbnail and 'small' version cache. If you experience problems with a particular picture, * simply delete that pictures thumbnail and small version in ./thumbs to have it regenerated. Deleting ./thumbs will cause * all of the pictures to be regenerated on the next page load. * * Some web hosts may restrict the number of seconds a PHP script can run. If you have a large gallery (or more likely large * pictures) it may take several page loads for the gallery to load successfuly. However, once the images are cached, there * should be no problems loading the gallery quickly. * * Also, if you have multiple galleries, I recommend puting the script in your home directory and soft linking to it. This way, * if you have the need to change the script, you don't have to change every version ;-). Dynamic titles of galleries is supported. * Simply put a file called "title" in the same directory as the photos, and put the title of the gallery on the first line of that file. */ // title of the page $title = "absent"; $handle = fopen("title", 'r'); $title = fgets($handle); fclose($handle); // this is the directory the thumbnails will be saved to $thumbsfolder='./thumbs/'; // the prefix to use for the generated thumbnails $thumbprefix="tn_"; // the prefix to use for the generated 'small' files $smallprefix="sm_"; // start the script $pics=ls('.',"jpg,JPG,JPEG,jpeg,png,PNG"); // make the thumbs directory if it doesn't exist if(!file_exists($thumbsfolder)) mkdir($thumbsfolder); // create all of the thumbnails if they don't already exist if ($pics[0]!="") { foreach ($pics as $p) { if(!file_exists($thumbsfolder.$thumbprefix.$p)) createthumb($p,$thumbsfolder.$thumbprefix.$p,150,150); if(!file_exists($thumbsfolder.$smallprefix.$p)) createthumb($p,$thumbsfolder.$smallprefix.$p,1024,1024); } } // now, render the page according to the request $slide = $_REQUEST['slide']; $nexturl = NULL; $prevurl = NULL; if($slide != NULL) { $nexturl = "?slide=".($slide+1)%count($pics); $prevurl = "?slide=".($slide-1 == -1 ? count($pics)-1 : $slide-1); } $time = $_REQUEST['time'] == NULL ? 5 : $_REQUEST['time']; ?>
Click on the picture (or the "small" link) for a ~1024x1024 50k image (good for slower connections). Click on "full" for the full resolution available.
Click here for a slideshow.
'.$p.'
'; } else { echo ""; echo ""; echo "