Subversion Repositories taios

Rev

Rev 240 | Rev 242 | 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
 
241 tom 40
write('<p class="bold">Back to Photos</p><br />');
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>');
55
        }
56
 
57
        $filename = 'albums/' . $dirName . '/' . $file;
58
        $size = getImageSizes($filename, 200, 200);
59
 
240 tom 60
        write('<td><a href="' . $filename . '"><img wdith="' . $size[0] . '" height="' . $size[1] . '" src="' . $filename . '" /></a></td>');
238 tom 61
 
62
        $i++;
236 tom 63
    }
64
}
65
 
238 tom 66
write('</tr>');
67
write('<table>');
68
 
236 tom 69
$page->drawFooter();
70
 
71
?>
72