Subversion Repositories taios

Compare Revisions

Ignore whitespace Rev 237 → Rev 238

/photos/album.php
2,6 → 2,31
 
require '../_taios.php';
 
function getImageSizes($sourceImageFilePath, $maxResizeWidth, $maxResizeHeight) {
 
$size = getimagesize($sourceImageFilePath);
$origWidth = $size[0];
$origHeight = $size[1];
 
$resizedWidth = $origWidth;
$resizedHeight = $origHeight;
if ($resizedWidth > $maxResizeWidth)
{
$aspectRatio = $maxResizeWidth / $resizedWidth;
$resizedWidth = round($aspectRatio * $resizedWidth);
$resizedHeight = round($aspectRatio * $resizedHeight);
}
if ($resizedHeight > $maxResizeHeight)
{
$aspectRatio = $maxResizeHeight / $resizedHeight;
$resizedWidth = round($aspectRatio * $resizedWidth);
$resizedHeight = round($aspectRatio * $resizedHeight);
}
return array($origWidth, $origHeight, $resizedWidth, $resizedHeight);
}
 
$page = new Taios_Page('Photo Albums', '../');
$page->drawHeader();
$page->drawMiddle();
12,15 → 37,33
$page->redirect('index.php');
}
 
write('<table>');
write('<tr>');
 
$i = 0;
 
$dir = dir('albums/' . $dirName);
while (($file = $dir->read()) !== false)
{
if ($file[0] != '.')
{
write('<p><img src="albums/' . $dirName . '/' . $file . '" /></p>');
if ($i >= 5)
{
write('</tr><tr>');
}
$filename = 'albums/' . $dirName . '/' . $file;
$size = getImageSizes($filename, 200, 200);
write('<td><img wdith="' . $size[2] . '" height="' . $size[3] . '" src="' . $filename . '" /></td>');
$i++;
}
}
 
write('</tr>');
write('<table>');
 
$page->drawFooter();
 
?>