Subversion Repositories taios

Rev

Rev 300 | Rev 327 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

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($resizedWidth, $resizedHeight);
}

$page = new Taios_Page('Photo Albums', '../');
$page->drawHeader();
$page->drawMiddle();

$dirName = $_GET['dir'];
if (empty($dirName))
{
    $page->redirect('index.php');
}

write('<p class="bold"><a href="index.php">Back to Photos</a></p><br />');

write('<table>');
write('<tr>');

$i = 0;

$dir = dir('albums/' . $dirName);
while (($file = $dir->read()) !== false)
{
    if ($file[0] != '.')
    {
        if ($i >= 4)
        {
            write('</tr><tr>');
            $i = 0;
        }
   
        $filename = 'albums/' . $dirName . '/' . $file;
        $size = getImageSizes($filename, 200, 200);
   
        write('<td><a href="' . $filename . '"><img width="' . $size[0] . '" height="' . $size[1] . '" src="' . $filename . '" /></a></td>');
       
        $i++;
    }
}

write('</tr>');
write('<table>');

$page->drawFooter();

?>