Subversion Repositories taios

Rev

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

Rev Author Line No. Line
236 tom 1
<?php
2
 
3
require '../_taios.php';
4
 
238 tom 5
function getImageSizes($sourceImageFilePath,  $maxResizeWidth, $maxResizeHeight) {
6
 
7
    $size = getimagesize($sourceImageFilePath);
8
    $origWidth = $size[0];
9
    $origHeight = $size[1];
10
 
11
    $resizedWidth = $origWidth;
12
    $resizedHeight = $origHeight;
13
 
14
    if ($resizedWidth > $maxResizeWidth)
15
    {
16
        $aspectRatio = $maxResizeWidth / $resizedWidth;
17
        $resizedWidth = round($aspectRatio * $resizedWidth);
18
        $resizedHeight = round($aspectRatio * $resizedHeight);
19
    }
20
    if ($resizedHeight > $maxResizeHeight)
21
    {
22
        $aspectRatio = $maxResizeHeight / $resizedHeight;
23
        $resizedWidth = round($aspectRatio * $resizedWidth);
24
        $resizedHeight = round($aspectRatio * $resizedHeight);
25
    }
26
 
239 tom 27
    return array($resizedWidth, $resizedHeight);
238 tom 28
}
29
 
236 tom 30
$page = new Taios_Page('Photo Albums', '../');
31
$page->drawHeader();
32
$page->drawMiddle();
33
 
34
$dirName = $_GET['dir'];
35
if (empty($dirName))
36
{
37
    $page->redirect('index.php');
38
}
39
 
242 tom 40
write('<p class="bold"><a href="index.php">Back to Photos</a></p><br />');
241 tom 41
 
238 tom 42
write('<table>');
43
write('<tr>');
44
 
45
$i = 0;
46
 
236 tom 47
$dir = dir('albums/' . $dirName);
48
while (($file = $dir->read()) !== false)
49
{
50
    if ($file[0] != '.')
51
    {
239 tom 52
        if ($i >= 4)
238 tom 53
        {
54
            write('</tr><tr>');
300 tom 55
            $i = 0;
238 tom 56
        }
57
 
58
        $filename = 'albums/' . $dirName . '/' . $file;
59
        $size = getImageSizes($filename, 200, 200);
60
 
301 tom 61
        write('<td><a href="' . $filename . '"><img width="' . $size[0] . '" height="' . $size[1] . '" src="' . $filename . '" /></a></td>');
238 tom 62
 
63
        $i++;
236 tom 64
    }
65
}
66
 
238 tom 67
write('</tr>');
68
write('<table>');
69
 
236 tom 70
$page->drawFooter();
71
 
72
?>
73