// // SPA : Simple Photo Album. // version 0.2 // author: Ilann Cohen - http://ilannweb.free.fr // //You may customize the parameters sections // // START OF PARAMETERS SECTION $doc_title = "Album generated by Simple Photo Album"; //web page title $columns=4; //number of images per line $ratio=5; //ratio imageSize / thumbnailImageSize $quality=5; //thumbnail image quality (0: worst to 100:best) $scriptname= "index.php"; //filename of this script $thumb_dir = "thumb"; //directory created to stored small images $thumb_prefix = "thumb_"; //prefix for generated images // END OF PARAMETERS SECTION echo "\n
\n
\n\n";
$mydirectory= '.'; //directory in which images are fetched
$counter=0;
$nbfiles = 0;
$currfile = "";
$filestab[0] = "";
$handle=opendir($mydirectory);
//create a directory for thumbnail images
if (! is_dir($thumb_dir))
{
mkdir($thumb_dir, 0777);
}
while ($currfile = readdir($handle))
{
// We get the extension of the current file and keep only image files
$extension= strtolower(substr( strrchr( $currfile, "." ), 1 ));
if ($extension== "gif" || $extension== "jpg" || $extension== "jpeg" ||
$extension== "png")
{
$nbfiles++;
$currfile = trim($currfile);
$filestab[$nbfiles] = $currfile;
if ($ishome == "")
{
$size = GetImageSize($currfile);
$width = $size[0] / $ratio;
$height = $size[1] / $ratio;
$format = $size[2]; //1 = GIF, 2 = JPG, 3 = PNG, 5 = PSD, 6 = BMP
$currthumbfile = "./" . $thumb_dir . "/" . $thumb_prefix . $currfile;
if (! file_exists($currthumbfile))
{
//GIF format is not supported anymore by GD lib...
if ($format == 2) //JPG
$im = imagecreatefromjpeg($currfile);
else if ($format == 3) //PNG
$im = imagecreatefrompng($currfile);
if (!$im)
{
$currthumbfile = $currfile;
}
else
{
Imagejpeg($im, $currthumbfile, $quality);
ImageDestroy($im);
}
}
$currfile = str_replace(" ","%20",$currfile); // Allow filenames with space characters
$currthumbfile = str_replace(" ","%20",$currthumbfile); // Allow filenames with space characters
echo "\n";
echo "\n";
$currfile = str_replace(" ","%20",$currfile); //Clean display of filenames with space characters
echo "\n";
$counter++;
if ($counter == $columns)
{
$counter = 0;
echo "
";
}
}
}
}
closedir($handle);
if ($ishome == 1)
{
echo "
\n";
$filename = str_replace(" ","%20",$filename); // Allow filenames with space characters
$filename = stripslashes($filename); // Allow filenames with ' characters
echo "\n";
$display = str_replace("%20"," ",$filename); // Clean display of filenames with space characters
echo "
$display
";
echo "
\n\n";
if ($filenumber != 1)
{
$prevnumber = $filenumber - 1;
$filestab[$prevnumber] = str_replace(" ","%20",$filestab[$prevnumber]); // Allow filenames with space characters
echo "[";
echo " << Previous] \n";
}
echo " [Main Page] \n";
echo " \n" ;
if ($filenumber != $nbfiles)
{
$nextnumber = $filenumber + 1;
$filestab[$nextnumber] = str_replace(" ","%20",$filestab[$nextnumber]); // Allow filenames with space characters
echo "[";
echo "Next >>]\n";
}
echo "\n\n";
}
?>