/*
Slide show written by Kyoorius 8/2/00
Use and modify if u like.
kyoorius@techfreakz.org
*/
$title="";
$maxx=100; $maxy=100;
function createthumbnail ($x,$y,$i,$dest) {
if ($x) {$maxx=$x;} else {$maxx=50;}
if ($y) {$maxy=$y;} else {$maxy=50;}
$tmp=strtoupper($i);
if (eregi(".JPG",$i)) {
$im=@ImageCreateFromJPEG($i);
}
if (eregi(".GIF",$i) || eregi(".PNG",$i)) {
$im=@ImageCreateFromPNG($i);
}
$x=imagesx($im);
$y=imagesy($im);
if ($dest=="smjpg") {
$r=$x/$y;
$ix=0;$iy=0;
if (($maxx/$maxy)<($r)) { $tx=$maxx; $ty=$maxx/$r;}
else {$ty=$maxy; $tx=$maxy*$r;}
$im2 = imagecreate ($tx,$ty);
}
else {
$im2 = imagecreate($maxx,$maxy);
$bg = ImageColorAllocate ($im2, 255,255,255);
imagefilledrectangle ($im2,0,0,$maxx,$maxy,$bg);
if ($x>$y) {$tx=$maxx; $ty=$y/$x*$maxx; $iy=($maxy-$ty)/2; $ix=0;}
else {$ty=$maxy; $tx=$x/$y*$maxy; $ix=($maxx-$tx)/2;$iy=0;}
}
imagecopyresized($im2,$im,$ix,$iy,0,0,$tx,$ty,$x,$y);
if ($dest=="smjpg") {
header ("Content-type: image/jpeg");
imagejpeg($im2,"",75);
#header ("Content-type: image/gif");
#imagepng($im2);
}
elseif ($dest) {
imagepng($im2,$dest);
chmod ($dest,0777);
}
else {
header ("Content-type: image/gif");
imagepng($im2);
}
}
function displaythumbnails ($data) {
global $maxx,$maxy,$size;
$x=0;
if (!file_exists("thumbs")) {
mkdir("thumbs",0777);
}
foreach ($data as $tmp) {
$x++;
list($file,$msg)=explode(",",$tmp);
$file=chop($file);
if (!file_exists("./thumbs/$file")) {
createthumbnail($maxx,$maxy,$file,"./thumbs/$file");
}
print "";
if (file_exists("./thumbs/$file")) {
print " \n";
}
}
error_reporting(1); # supress warnings about not being able to create "descriptions" file
if ($tn) {createthumbnail($maxx,$maxy,$tn); exit;}
if ($smpic) {createthumbnail(300,300,$smpic,"smjpg"); exit;}
if (!$slide) {$thumbnails=1;}
$data=array();
if (file_exists("descriptions")) {
$data=file("descriptions");
if (strtoupper(substr($data[0],0,6)) == "TITLE=") {
$title=substr($data[0],6);
$trash=array_shift($data);
}
}
else {
$handle=opendir('.');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != ".." && (eregi(".gif",$file) || eregi(".jpg",$file))) {
array_push($data,$file);
}
}
closedir($handle);
# try and create the description file
$fp=fopen("descriptions","w");
if ($fp) {
fputs($fp,"title=\n");
foreach ($data as $out) {
fputs($fp,"$out\n");
}
fclose($fp);
chmod("descriptions",0777);
}
}
?>
if ($thumbnails) { ?>
"; ?>
"; } ?>