SourceCodes / Codeschnipsel
|
001 | <?
002 |
003 | ############################
004 |
005 | ## ##
006 |
007 | ## GalleryScript v1.0 ##
008 |
009 | ## copyright 2009 Ch. Lange ##
010 |
011 | ## ##
012 |
013 | ############################
014 |
015 |
016 |
017 | ### Thumb size
018 |
019 | $twidht = 220; $theight = 165; // set desired thumbsize like 800x600
020 |
021 | ### Table
022 |
023 | $rows = 3; $layout = "center"; // set desired number of thumbs in a row
024 |
025 | ### Folder
026 |
027 | $verz = "./gfx/new"; // set folder where you keep grafics
028 |
029 |
030 |
031 | ### End Config
032 |
033 | $folder = opendir($verz);
034 |
035 | $filetype = array("jpg", "jpeg", "gif", "png", "bmp");
036 |
037 | $pics = array();
038 |
039 | while ($file = readdir ($folder)) {
040 |
041 | if(in_array(substr(strtolower($file), strrpos($file,".") + 1),$filetype))
042 |
043 | {
044 |
045 | array_push($pics,$verz."/".$file);
046 |
047 | }
048 |
049 | }
050 |
051 | closedir($folder);
052 |
053 |
054 |
055 | echo "<table align=\"$layout\"><tr>";
056 |
057 |
058 |
059 | for ( $x = 0; $x < count ( $pics ); $x++ )
060 |
061 | {
062 |
063 | list($width, $height,) = getimagesize($pics[$x]);
064 |
065 | if ($width > $twidht) {
066 |
067 | $w = $width/$twidht;
068 |
069 | $h = $height/$w;
070 |
071 | $h = floor($h);
072 |
073 | $w = $twidht;
074 |
075 |
076 |
077 | if ($h > $theight) {
078 |
079 | $h = $h/$theight;
080 |
081 | $w = $twidht/$h;
082 |
083 | $w = floor($w);
084 |
085 | $h = $theight;
086 |
087 | }
088 |
089 | echo "
090 |
091 | <td align=\"center\" valign=\"bottom\">
092 |
093 | <a href=\"$pics[$x]\" target=\"_blank\">
094 |
095 | <img src=\"$pics[$x]_thumb\" width=\"$w\" height=\"$h\" border=\"0\" /></a><br />
096 |
097 | <span style=\"font-size:8pt; font-style:italic;\">
098 |
099 | <b>Resolution:</b> $width x $height </span><p />
100 |
101 | </td>";
102 |
103 |
104 |
105 | if(($x + 1) % $rows == 0){
106 |
107 | echo "</tr><tr>";
108 |
109 | }
110 |
111 | }
112 |
113 | elseif ($height > $theight) {
114 |
115 | $h = $height/$theight;
116 |
117 | $w = $width/$h;
118 |
119 | $w = floor($w);
120 |
121 | echo "
122 |
123 | <td align=\"center\" valign=\"bottom\">
124 |
125 | <a href=\"$pics[$x]\" target=\"_blank\">
126 |
127 | <img src=\"$pics[$x]\" width=\"$w\" height=\"$theight\" border=\"0\" /></a><br />
128 |
129 | <span style=\"font-size:8pt; font-style:italic;\">
130 |
131 | <b>Resolution:</b> $width x $height </span><p />
132 |
133 | </td>";
134 |
135 |
136 |
137 | if(($x + 1) % $rows == 0){
138 |
139 | echo "</tr><tr>";
140 |
141 | }
142 |
143 | }
144 |
145 | else {
146 |
147 | echo "
148 |
149 | <td align=\"center\" valign=\"bottom\">
150 |
151 | <img src=\"$pics[$x]\" /><br />
152 |
153 | <span style=\"font-size:8pt; font-style:italic; font-variant: small-caps;\">
154 |
155 | <b>Resolution:</b> $width x $height </span><p />
156 |
157 | </td>";
158 |
159 |
160 |
161 | if(($x + 1) % $rows == 0){
162 |
163 | echo "</tr><tr>";
164 |
165 | }
166 |
167 | }
168 |
169 | }
170 |
171 | echo "</tr></table>";
172 |
173 |
174 |
175 | ?>
|