$source_aspect_ratio) { $thumbnail_image_width = (int) (THUMBNAIL_IMAGE_MAX_HEIGHT * $source_aspect_ratio); $thumbnail_image_height = THUMBNAIL_IMAGE_MAX_HEIGHT; } else { $thumbnail_image_width = THUMBNAIL_IMAGE_MAX_WIDTH; $thumbnail_image_height = (int) (THUMBNAIL_IMAGE_MAX_WIDTH / $source_aspect_ratio); } $thumbnail_gd_image = imagecreatetruecolor($thumbnail_image_width, $thumbnail_image_height); imagecopyresampled($thumbnail_gd_image, $source_gd_image, 0, 0, 0, 0, $thumbnail_image_width, $thumbnail_image_height, $source_image_width, $source_image_height); imagejpeg($thumbnail_gd_image, $thumbnail_image_path, 90); imagedestroy($source_gd_image); imagedestroy($thumbnail_gd_image); return true; } // End of function ?> Photo Archive
Viewing: $folder
"; // If your in a sub folder show an 'Up one level' button if($folder != 'images/') { // Remove the preceding / from the string (i.e. last character) $upOne = substr($folder, 0, -1); // Explode the string wherever a / appears (i.e. separate the folders) $folderExp = explode("/", $upOne); // Get the last section of the explode (i.e. the current folder name) $end = end($folderExp); // Remove the 'images/' section from the front of the string $upOne = str_replace('images/', '', $upOne); // Remove the last folder name $upOne = str_replace($end, '', $upOne); // Remove the preceding / from the string (i.e. the last character) $upOne = substr($upOne, 0, -1); // Show a link to go up one folder echo ""; echo "
"; echo "
"; } /* List the folders */ foreach(glob("$folder*", GLOB_ONLYDIR) as $dir) { // Get the name of the folder by removing the current folder string $dirShort = str_replace($folder, '', $dir); // Remove 'images/' from the beginning of the string $dir = str_replace('images/', '', $dir); // Show a link for each folder echo ""; echo "
"; echo "$dirShort
"; echo "Preview of $dirShort:
"; // Show the first 10 thumbnails from the album foreach(array_slice(glob("images/$dir/{*.jpg,*.gif,*.png,*.tif,*.jpeg}", GLOB_BRACE), 0, 9) as $entry) { $thumb = 'thumbs' . substr($entry, 6); if (file_exists($thumb)) { $entry = $thumb; } echo "
"; echo "
"; echo "
"; } echo "
"; echo "
"; } /* Search for text files within the folder and generate an information link for each */ foreach(glob("$folder*.txt", GLOB_BRACE) as $info) { // Explode the sting which contains the path to the image $fileName = explode("/", $info); // Get the last section of the sting (i.e. the image name) $fileName = end($fileName); echo ""; echo "

$fileName
"; echo "
"; } // Count the images$folder $count = 0; foreach(glob("$folder{*.jpg,*.gif,*.png,*.tif,*.jpeg}", GLOB_BRACE) as $entry) { $count = $count + 1; } // if there are more than 50 images show the page buttons if($count > $maxImages) { echo ""; // Get the page no from the URL if its set, otherwise set it to 1 if(isset($_GET['page']) && is_numeric($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } // work out the first image to show from the page number $start = ($page - 1); $start = ($start * $maxImages); // Work out the total number of pages $noPages = ceil($count / $maxImages); // Get the current folder $currFolder = str_replace('images/', '', $folder); // Remove the last character (the trailing /) $currFolder = substr($currFolder, 0, -1); // If the page isn't 1 show the previous page link if($page != 1) { $previous = ($page - 1); echo ""; echo ""; } // If the page isn't the last one show the next link if($page != $noPages) { $next = ($page + 1); echo ""; echo ""; } // Work out the last image for the to from header section $to = ($start + $maxImages); $from = ($start + 1); if ($to > $count) { // If to is greater than the number of images, show the number of images $to = $count; } $toFrom = "$from to $to of "; } else { $start = 0; // Create the to and from images for the header if($count != 0) { $toFrom = "1 to $count of "; } else { $toFrom = ""; } } // Show number of images in folder within the header echo "
$toFrom$count images
"; /* List the images in the directory */ foreach(array_slice(glob("$folder{*.jpg,*.gif,*.png,*.tif,*.jpeg}", GLOB_BRACE), $start, $maxImages) as $entry) { $exif_data = exif_read_data ($entry); $exif = ''; if (!empty($exif_data['DateTimeOriginal'])) { $exif = 'Date (' . $exif_data['DateTimeOriginal'] . ')'; } if (!empty($exif_data['Make'])) { $exif = $exif . ' Equipment (' . $exif_data['Make'] . ' | ' . $exif_data['Model'] . ')'; } if ($exif != '') { $exif = $exif . ' - '; } // Explode the sting which contains the path to the image $imgName = explode("/", $entry); // Get the last section of the sting (i.e. the image name) $imgName = end($imgName); // Set the thumbnail directory $thumbDir = 'thumbs' . str_replace($imgName, '', substr($entry, 6)); if (!file_exists($thumbDir)) { // If the directory doesn't exist, create it mkdir($thumbDir, 0777, true); } // Set the name of the thumbnail $thumb = 'thumbs' . substr($entry, 6); if (!file_exists($thumb)) { // If the thumb doesn't exist create it by copying the original file and resizing it generate_image_thumbnail($entry, $thumb); } // Show a thumb nail and Lightbox link for each image echo ""; echo "

$imgName
"; echo "
"; } ?>