Subversion Repositories taios

Rev

Rev 239 | Rev 241 | 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
 
238 tom 40
write('<table>');
41
write('<tr>');
42
 
43
$i = 0;
44
 
236 tom 45
$dir = dir('albums/' . $dirName);
46
while (($file = $dir->read()) !== false)
47
{
48
    if ($file[0] != '.')
49
    {
239 tom 50
        if ($i >= 4)
238 tom 51
        {
52
            write('</tr><tr>');
53
        }
54
 
55
        $filename = 'albums/' . $dirName . '/' . $file;
56
        $size = getImageSizes($filename, 200, 200);
57
 
240 tom 58
        write('<td><a href="' . $filename . '"><img wdith="' . $size[0] . '" height="' . $size[1] . '" src="' . $filename . '" /></a></td>');
238 tom 59
 
60
        $i++;
236 tom 61
    }
62
}
63
 
238 tom 64
write('</tr>');
65
write('<table>');
66
 
236 tom 67
$page->drawFooter();
68
 
69
?>
70