]> Pileus Git - ~andy/ct/blob - gallery/old/gen_thumbs.php
Add old version of gallery using php
[~andy/ct] / gallery / old / gen_thumbs.php
1 <?php
2         $jpgs = shell_exec("cd images && ls -1 *.jpg");
3         $jpgs = explode("\n", $jpgs);
4         foreach ($jpgs as $jpg) {
5                 #imagecreatefromjpeg($jpg);
6                 
7
8                 ### begin resize ###
9                 list($sw, $sh) = getimagesize("images/$jpg");
10                 $mw = 200;
11                 $mh = 200;
12                 if ($sw > $mw || $sh > $mh) {
13                         if ($sw > $sh) {
14                                 $dw = $mw;
15                                 $dh = $sh*($mw/$sw);
16                         }
17                         if ($sh > $sw) {
18                                 $dh = $mh;
19                                 $dw = $sw*($mh/$sh);
20                         }
21                 } else {
22                         $dw = $sw;
23                         $dh = $sh;
24                 }
25                 $src_image = imagecreatefromjpeg("images/$jpg");
26                 $dst_image = imagecreatetruecolor($dw, $dh);
27                 imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dw, $dh, $sw, $sh);
28                 imagejpeg($dst_image, "thumbs/{$jpg}");
29                 ### end resize ###
30
31                 print("<br>".$jpg);
32         }
33 ?>